@ryupold/vode 1.8.12 → 1.9.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.
- package/dist/vode.cjs.min.js +2 -2
- package/dist/vode.d.ts +23 -25
- package/dist/vode.es5.min.js +5 -5
- package/dist/vode.js +30 -7
- package/dist/vode.min.js +1 -1
- package/dist/vode.min.mjs +1 -1
- package/dist/vode.mjs +30 -7
- package/dist/vode.tests.mjs +220 -36
- package/package.json +4 -4
- package/src/state-context.ts +65 -38
- package/src/vode.ts +10 -3
- package/test/tests-app.ts +1 -2
- package/test/tests-catch.ts +61 -1
- package/test/tests-patch-advanced.ts +20 -21
- package/test/tests-state-context.ts +175 -23
package/dist/vode.min.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var E={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 K(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=E.requestAnimationFrame,t.asyncRenderer=E.startViewTransition,t.isRendering=0,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]);async function r(c,S){t.stats.liveEffectCount++;try{let d=await c;await o.patch(d,S)}finally{t.stats.liveEffectCount--}}async function f(c,S){let d=c;t.stats.liveEffectCount++;try{let p=await d.next();for(;p.done===!1;){t.stats.liveEffectCount++;try{await o.patch(p.value,S),p=await d.next()}finally{t.stats.liveEffectCount--}}await o.patch(p.value,S)}finally{t.stats.liveEffectCount--}}Object.defineProperty(n,"patch",{enumerable:!1,configurable:!0,writable:!1,value:(c,S)=>{for(;typeof c=="function";)c=c(t.state);if(!(!c||typeof c!="object")){if(t.stats.patchCount++,c?.next)return f(c,S);if(c.then)return r(c,S);if(Array.isArray(c))if(c.length>0)for(let d of c)o.patch(d,!document.hidden&&!!t.asyncRenderer);else{m(t.state,t.qAsync,!0),t.qAsync=null;try{E.currentViewTransition?.skipTransition()}catch{}t.stats.syncRenderPatchCount++,t.renderSync()}else S?(t.stats.asyncRenderPatchCount++,t.qAsync=m(t.qAsync||{},c,!1),t.renderAsync()):(t.stats.syncRenderPatchCount++,m(t.state,c,!0),t.renderSync())}}});function i(c){let S=performance.now(),d=s(t.state);if(t.vode=P(t.state,e.parentElement,0,0,t.vode,d),e.tagName.toUpperCase()!==d[0].toUpperCase()&&(e=t.vode.node,e._vode=t),!c){t.stats.lastSyncRenderTime=performance.now()-S;let p=t.isRendering!==t.stats.syncRenderPatchCount;t.stats.syncRenderCount++,t.isRendering=0,p&&t.renderSync()}}let l=i.bind(null,!1),g=i.bind(null,!0);Object.defineProperty(t,"renderSync",{enumerable:!1,configurable:!0,writable:!1,value:()=>{t.isRendering||(t.isRendering=t.stats.syncRenderPatchCount,t.syncRenderer(l))}}),Object.defineProperty(t,"renderAsync",{enumerable:!1,configurable:!0,writable:!1,value:async()=>{if(t.isAnimating||!t.qAsync||(await E.currentViewTransition?.updateCallbackDone,t.isAnimating||!t.qAsync||document.hidden))return;t.isAnimating=!0;let c=performance.now();try{t.state=m(t.state,t.qAsync,!0),t.qAsync=null,E.currentViewTransition=t.asyncRenderer(g),await E.currentViewTransition?.updateCallbackDone}finally{t.stats.lastAsyncRenderTime=performance.now()-c,t.stats.asyncRenderCount++,t.isAnimating=!1}t.qAsync&&t.renderAsync()}}),t.state=o;let u=e;u._vode=t;let x=Array.from(e.parentElement.children).indexOf(e),T=t.stats.syncRenderPatchCount;t.isRendering=t.stats.syncRenderPatchCount,t.vode=P(n,e.parentElement,x,x,D(e,!0),s(n));let y=t.stats.syncRenderPatchCount!==T;t.isRendering=0,t.stats.syncRenderCount++,y&&t.renderSync();for(let c of a)o.patch(c);return c=>o.patch(c)}function I(e){if(e?._vode){let s=function(t){if(!t?.node)return;let o=b(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)I(t.node);else{let r=L(t);if(r)for(let f of r)s(f)}};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)I(s)}function D(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&&D(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 child vode");if(n.__memo){let s=n;n=a=>s(a)}return n.__memo=e,n}function w(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 X(e){return e}function Y(e){return e?Array.isArray(e)?e[0]:typeof e=="string"||e.nodeType===Node.TEXT_NODE?"#text":void 0:void 0}function b(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=A(e);return n>0?e.slice(n):null}function W(e){let n=A(e);return n<0?0:e.length-n}function $(e,n){let s=A(e);if(s>0)return e[n+s]}function A(e){return b(e)?e.length>2?2:-1:Array.isArray(e)&&e.length>1?1:-1}function m(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]=m({},t,s):typeof o=="object"?m(e[a],t,s):e[a]=m({},t,s):Array.isArray(t)?e[a]=[...t]:t instanceof Date?e[a]=new Date(t):e[a]=m({},t,s)}else t===void 0&&s?delete e[a]:e[a]=t}return e}function P(e,n,s,a,t,o,r){try{o=F(e,o,t);let f=!o||typeof o=="number"||typeof o=="boolean";if(o===t||!t&&f)return t;let i=t?.nodeType===Node.TEXT_NODE,l=i?t:t?.node;if(f){R(e,t),l?.remove();return}let g=!f&&B(o),u=!f&&k(o),x=!!o&&typeof o!="string"&&!!(o?.node||o?.nodeType===Node.TEXT_NODE);if(!g&&!u&&!x&&!t)throw new Error("Invalid vode: "+typeof o+" "+JSON.stringify(o));if(x&&g?o=o.wholeText:x&&u&&(o=[...o]),i&&g)return l.nodeValue!==o&&(l.nodeValue=o),t;if(g&&(!l||!i)){let T=document.createTextNode(o);if(l)R(e,t),l.replaceWith(T);else{let y=!1;for(let c=a;c<n.childNodes.length;c++){let S=n.childNodes[c];if(S){S.before(T),y=!0;break}}y||n.appendChild(T)}return T}if(u&&(!l||i||t[0]!==o[0])){let T=o;1 in T&&(T[1]=F(e,T[1],void 0));let y=b(o);y?.xmlns!==void 0&&(r=y.xmlns);let c=r?document.createElementNS(r,o[0]):document.createElement(o[0]);if(o.node=c,H(e,c,void 0,y,r??null),y&&"catch"in y&&(o.node.catch=null,o.node.removeAttribute("catch")),l)R(e,t),l.replaceWith(c);else{let d=!1;for(let p=a;p<n.childNodes.length;p++){let h=n.childNodes[p];if(h){h.before(c),d=!0;break}}d||n.appendChild(c)}let S=A(o);if(S>0){let d=y?2:1,p=0;for(let h=0;h<o.length-S;h++){let O=o[h+S],C=P(e,c,h,p,void 0,O,r??null);o[h+d]=C,C&&p++}}return o._unmountCount=(y?.onUnmount?1:0)+V(o),typeof y?.onMount=="function"&&e.patch(y.onMount(e,c)),o}if(!i&&u&&t[0]===o[0]){o.node=l;let T=b(o),y=b(t);T?.xmlns!==void 0&&(r=T.xmlns),H(e,l,y,T,r),T?.catch&&y?.catch!==T.catch&&(o.node.catch=null,o.node.removeAttribute("catch"));let c=A(o),S=A(t);if(c>0){let d=0;for(let p=0;p<o.length-c;p++){let h=o[p+c],O=S>0?t[p+S]:void 0,C=P(e,l,p,d,O,h,r);o[p+c]=C,C&&d++}}if(S>0){let d=c>0?o.length-c:0;for(let p=t.length-1-S;p>=d;p--)P(e,l,p,p,t[p+S],void 0,r)}return o._unmountCount=(T?.onUnmount?1:0)+V(o),o}}catch(f){let i=b(o)?.catch;if(i){let l=typeof i=="function"?i(e,f):i;return P(e,n,s,a,D(o?.node||t?.node,!0),l,r)}else throw f}}function R(e,n){if(!n||!Array.isArray(n)||(n._unmountCount|0)===0)return;let s=L(n);if(s)for(let t=s.length-1;t>=0;t--)R(e,s[t]);let a=b(n);typeof a?.onUnmount=="function"&&e.patch(a.onUnmount(e,n.node))}function V(e){let n=L(e);if(!n)return 0;let s=0;for(let a of n)a&&Array.isArray(a)&&(s+=a._unmountCount|0);return s}function k(e){return Array.isArray(e)&&e.length>0&&typeof e[0]=="string"}function B(e){return typeof e=="string"||e?.nodeType===Node.TEXT_NODE}function F(e,n,s){for(;typeof n=="function"&&!n.__memo;)n=n(e);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 o=!0;for(let r=0;r<a.length;r++)if(a[r]!==t[r]){o=!1;break}if(o)return s}for(;typeof n=="function";)n=n(e);return typeof n=="object"&&(n.__memo=a),n}function H(e,n,s,a,t){if(!a&&!s)return;let o=t!==void 0;if(s)for(let r in s){let f=s[r],i=a?.[r];f!==i&&(a?a[r]=M(e,n,r,f,i,o):M(e,n,r,f,void 0,o))}if(a&&s){for(let r in a)if(!(r in s)){let f=a[r];a[r]=M(e,n,r,void 0,f,o)}}else if(a)for(let r in a){let f=a[r];a[r]=M(e,n,r,void 0,f,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 f=a[r],i=t[r];f!==i&&(n.style[r]=i)}}else for(let r in t)n.style[r]=t[r];else if(s==="class")t?n.setAttribute("class",G(t)):n.removeAttribute("class");else if(s[0]==="o"&&s[1]==="n")if(t){let r=null;if(typeof t=="function"){let f=t;r=i=>e.patch(f(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 G(e){return typeof e=="string"?e:Array.isArray(e)?e.map(G).join(" "):typeof e=="object"?Object.keys(e).filter(n=>e[n]).join(" "):""}var Q="a",z="abbr",Z="address",tt="area",et="article",nt="aside",ot="audio",at="b",st="base",rt="bdi",ct="bdo",it="blockquote",lt="body",ft="br",pt="button",St="canvas",ut="caption",dt="cite",Tt="code",yt="col",gt="colgroup",ht="data",xt="datalist",mt="dd",bt="del",Et="details",Pt="dfn",At="dialog",Ct="div",Mt="dl",Rt="dt",Nt="em",Ot="embed",Dt="fieldset",Lt="figcaption",vt="figure",It="footer",Vt="form",Ft="h1",Ht="h2",Gt="h3",jt="h4",Ut="h5",kt="h6",Bt="head",_t="header",Kt="hgroup",qt="hr",wt="html",Xt="i",Yt="iframe",Wt="img",$t="input",Jt="ins",Qt="kbd",zt="label",Zt="legend",te="li",ee="link",ne="main",oe="map",ae="mark",se="menu",re="meta",ce="meter",ie="nav",le="noscript",fe="object",pe="ol",Se="optgroup",ue="option",de="output",Te="p",ye="picture",ge="pre",he="progress",xe="q",me="rp",be="rt",Ee="ruby",Pe="s",Ae="samp",Ce="script",Me="search",Re="section",Ne="select",Oe="slot",De="small",Le="source",ve="span",Ie="strong",Ve="style",Fe="sub",He="summary",Ge="sup",je="table",Ue="tbody",ke="td",Be="template",_e="textarea",Ke="tfoot",qe="th",we="thead",Xe="time",Ye="title",We="tr",$e="track",Je="u",Qe="ul",ze="var",Ze="video",tn="wbr",en="animate",nn="animateMotion",on="animateTransform",an="circle",sn="clipPath",rn="defs",cn="desc",ln="ellipse",fn="feBlend",pn="feColorMatrix",Sn="feComponentTransfer",un="feComposite",dn="feConvolveMatrix",Tn="feDiffuseLighting",yn="feDisplacementMap",gn="feDistantLight",hn="feDropShadow",xn="feFlood",mn="feFuncA",bn="feFuncB",En="feFuncG",Pn="feFuncR",An="feGaussianBlur",Cn="feImage",Mn="feMerge",Rn="feMergeNode",Nn="feMorphology",On="feOffset",Dn="fePointLight",Ln="feSpecularLighting",vn="feSpotLight",In="feTile",Vn="feTurbulence",Fn="filter",Hn="foreignObject",Gn="g",jn="image",Un="line",kn="linearGradient",Bn="marker",_n="mask",Kn="metadata",qn="mpath",wn="path",Xn="pattern",Yn="polygon",Wn="polyline",$n="radialGradient",Jn="rect",Qn="set",zn="stop",Zn="svg",to="switch",eo="symbol",no="text",oo="textPath",ao="tspan",so="use",ro="view",co="annotation",io="annotation-xml",lo="maction",fo="math",po="merror",So="mfrac",uo="mi",To="mmultiscripts",yo="mn",go="mo",ho="mover",xo="mpadded",mo="mphantom",bo="mprescripts",Eo="mroot",Po="mrow",Ao="ms",Co="mspace",Mo="msqrt",Ro="mstyle",No="msub",Oo="msubsup",Do="msup",Lo="mtable",vo="mtd",Io="mtext",Vo="mtr",Fo="munder",Ho="munderover",Go="semantics";function j(...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(" "),f=new Set([...o,...r]);n=Array.from(f).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"&&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 if(typeof a=="object"&&typeof t=="object")n={...a,...t};else throw new Error(`cannot merge classes of ${a} (${typeof a}) and ${t} (${typeof t})`);else continue}return n}var N;function U(...e){N||(N=document.createElement("div"));try{let n=N.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{N.style.cssText=""}}function Ko(...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=U(n.style,s.style):a==="class"?n.class=j(n.class,s.class):n[a]=s[a]}return n}function wo(e){return new v(e,[])}var v=class e{constructor(n,s){this.state=n;this.keys=s;function a(i,l){if(s.length>1){let g=0,u=l[s[g]];for((typeof u!="object"||u===null)&&(l[s[g]]=u={}),g=1;g<s.length-1;g++){let x=u;u=u[s[g]],(typeof u!="object"||u===null)&&(x[s[g]]=u={})}u[s[g]]=i}else s.length===1?typeof l[s[0]]=="object"&&typeof i=="object"&&i!==null?Object.assign(l[s[0]],i):l[s[0]]=i:Object.assign(l,i)}function t(i){let l={};return a(i,l),l}function o(){if(s.length===0)return n;let i=n?n[s[0]]:void 0;for(let l=1;l<s.length&&i;l++)i=i[s[l]];return i}function r(i){a(i,n)}function f(i,l){l?n.patch([t(i)]):n.patch(t(i))}return new Proxy(this,{get:(i,l,g)=>{if(l==="state")return n;if(l==="get")return o;if(l==="put")return r;if(l==="patch")return f;let u=[...i.keys,String(l)];return new e(i.state,u)}})}state;keys;get(){}put(n){}patch(n){}};export{Q as A,z as ABBR,Z as ADDRESS,en as ANIMATE,nn as ANIMATEMOTION,on as ANIMATETRANSFORM,co as ANNOTATION,io as ANNOTATION_XML,tt as AREA,et as ARTICLE,nt as ASIDE,ot as AUDIO,at as B,st as BASE,rt as BDI,ct as BDO,it as BLOCKQUOTE,lt as BODY,ft as BR,pt as BUTTON,St as CANVAS,ut as CAPTION,an as CIRCLE,dt as CITE,sn as CLIPPATH,Tt as CODE,yt as COL,gt as COLGROUP,ht as DATA,xt as DATALIST,mt as DD,rn as DEFS,bt as DEL,cn as DESC,Et as DETAILS,Pt as DFN,At as DIALOG,Ct as DIV,Mt as DL,Rt as DT,ln as ELLIPSE,Nt as EM,Ot as EMBED,fn as FEBLEND,pn as FECOLORMATRIX,Sn as FECOMPONENTTRANSFER,un as FECOMPOSITE,dn as FECONVOLVEMATRIX,Tn as FEDIFFUSELIGHTING,yn as FEDISPLACEMENTMAP,gn as FEDISTANTLIGHT,hn as FEDROPSHADOW,xn as FEFLOOD,mn as FEFUNCA,bn as FEFUNCB,En as FEFUNCG,Pn as FEFUNCR,An as FEGAUSSIANBLUR,Cn as FEIMAGE,Mn as FEMERGE,Rn as FEMERGENODE,Nn as FEMORPHOLOGY,On as FEOFFSET,Dn as FEPOINTLIGHT,Ln as FESPECULARLIGHTING,vn as FESPOTLIGHT,In as FETILE,Vn as FETURBULENCE,Dt as FIELDSET,Lt as FIGCAPTION,vt as FIGURE,Fn as FILTER,It as FOOTER,Hn as FOREIGNOBJECT,Vt as FORM,Gn as G,Ft as H1,Ht as H2,Gt as H3,jt as H4,Ut as H5,kt as H6,Bt as HEAD,_t as HEADER,Kt as HGROUP,qt as HR,wt as HTML,Xt as I,Yt as IFRAME,jn as IMAGE,Wt as IMG,$t as INPUT,Jt as INS,Qt as KBD,zt as LABEL,Zt as LEGEND,te as LI,Un as LINE,kn as LINEARGRADIENT,ee as LINK,lo as MACTION,ne as MAIN,oe as MAP,ae as MARK,Bn as MARKER,_n as MASK,fo as MATH,se as MENU,po as MERROR,re as META,Kn as METADATA,ce as METER,So as MFRAC,uo as MI,To as MMULTISCRIPTS,yo as MN,go as MO,ho as MOVER,xo as MPADDED,qn as MPATH,mo as MPHANTOM,bo as MPRESCRIPTS,Eo as MROOT,Po as MROW,Ao as MS,Co as MSPACE,Mo as MSQRT,Ro as MSTYLE,No as MSUB,Oo as MSUBSUP,Do as MSUP,Lo as MTABLE,vo as MTD,Io as MTEXT,Vo as MTR,Fo as MUNDER,Ho as MUNDEROVER,ie as NAV,le as NOSCRIPT,fe as OBJECT,pe as OL,Se as OPTGROUP,ue as OPTION,de as OUTPUT,Te as P,wn as PATH,Xn as PATTERN,ye as PICTURE,Yn as POLYGON,Wn as POLYLINE,ge as PRE,he as PROGRESS,xe as Q,$n as RADIALGRADIENT,Jn as RECT,me as RP,be as RT,Ee as RUBY,Pe as S,Ae as SAMP,Ce as SCRIPT,Me as SEARCH,Re as SECTION,Ne as SELECT,Go as SEMANTICS,Qn as SET,Oe as SLOT,De as SMALL,Le as SOURCE,ve as SPAN,zn as STOP,Ie as STRONG,Ve as STYLE,Fe as SUB,He as SUMMARY,Ge as SUP,Zn as SVG,to as SWITCH,eo as SYMBOL,je as TABLE,Ue as TBODY,ke as TD,Be as TEMPLATE,no as TEXT,_e as TEXTAREA,oo as TEXTPATH,Ke as TFOOT,qe as TH,we as THEAD,Xe as TIME,Ye as TITLE,We as TR,$e as TRACK,ao as TSPAN,Je as U,Qe as UL,so as USE,ze as VAR,Ze as VIDEO,ro as VIEW,tn as WBR,K as app,$ as child,W as childCount,L as children,A as childrenStart,wo as context,X as createPatch,w as createState,I as defuse,E as globals,D as hydrate,q as memo,j as mergeClass,Ko as mergeProps,U as mergeStyle,b as props,Y as tag,_ as vode};
|
|
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 B(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.isRendering=0,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]);async function r(c,p){t.stats.liveEffectCount++;try{let d=await c;await o.patch(d,p)}finally{t.stats.liveEffectCount--}}async function l(c,p){let d=c;t.stats.liveEffectCount++;try{let f=await d.next();for(;f.done===!1;){t.stats.liveEffectCount++;try{await o.patch(f.value,p),f=await d.next()}finally{t.stats.liveEffectCount--}}await o.patch(f.value,p)}finally{t.stats.liveEffectCount--}}Object.defineProperty(n,"patch",{enumerable:!1,configurable:!0,writable:!1,value:(c,p)=>{for(;typeof c=="function";)c=c(t.state);if(!(!c||typeof c!="object")){if(t.stats.patchCount++,c?.next)return l(c,p);if(c.then)return r(c,p);if(Array.isArray(c))if(c.length>0)for(let d of c)o.patch(d,!document.hidden&&!!t.asyncRenderer);else{m(t.state,t.qAsync,!0),t.qAsync=null;try{P.currentViewTransition?.skipTransition()}catch{}t.stats.syncRenderPatchCount++,t.renderSync()}else p?(t.stats.asyncRenderPatchCount++,t.qAsync=m(t.qAsync||{},c,!1),t.renderAsync()):(t.stats.syncRenderPatchCount++,m(t.state,c,!0),t.renderSync())}}});function i(c){let p=performance.now();if(t.vode=E(t.state,e.parentElement,0,0,t.vode,s(t.state)),e.tagName.toLowerCase()!==t.vode[0].toLowerCase()&&(e=t.vode.node,e._vode=t),!c){t.stats.lastSyncRenderTime=performance.now()-p;let d=t.isRendering!==t.stats.syncRenderPatchCount;t.stats.syncRenderCount++,t.isRendering=0,d&&t.renderSync()}}let S=i.bind(null,!1),T=i.bind(null,!0);Object.defineProperty(t,"renderSync",{enumerable:!1,configurable:!0,writable:!1,value:()=>{t.isRendering||(t.isRendering=t.stats.syncRenderPatchCount,t.syncRenderer(S))}}),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 c=performance.now();try{t.state=m(t.state,t.qAsync,!0),t.qAsync=null,P.currentViewTransition=t.asyncRenderer(T),await P.currentViewTransition?.updateCallbackDone}finally{t.stats.lastAsyncRenderTime=performance.now()-c,t.stats.asyncRenderCount++,t.isAnimating=!1}t.qAsync&&t.renderAsync()}}),t.state=o;let u=e;u._vode=t;let h=Array.from(e.parentElement.children).indexOf(e),y=t.stats.syncRenderPatchCount;t.isRendering=t.stats.syncRenderPatchCount,t.vode=E(n,e.parentElement,h,h,v(e,!0),s(n)),e.tagName.toLowerCase()!==t.vode[0].toLowerCase()&&(e=t.vode.node,e._vode=t);let x=t.stats.syncRenderPatchCount!==y;t.isRendering=0,t.stats.syncRenderCount++,x&&t.renderSync();for(let c of a)o.patch(c);return c=>o.patch(c)}function I(e){if(e?._vode){let s=function(t){if(!t?.node)return;let o=b(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)I(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)I(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 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 child vode");if(n.__memo){let s=n;n=a=>s(a)}return n.__memo=e,n}function X(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 Y(e){return e}function W(e){return e?Array.isArray(e)?e[0]:typeof e=="string"||e.nodeType===Node.TEXT_NODE?"#text":void 0:void 0}function b(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=A(e);return n>0?e.slice(n):null}function $(e){let n=A(e);return n<0?0:e.length-n}function J(e,n){let s=A(e);if(s>0)return e[n+s]}function A(e){return b(e)?e.length>2?2:-1:Array.isArray(e)&&e.length>1?1:-1}function m(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]=m({},t,s):typeof o=="object"?m(e[a],t,s):e[a]=m({},t,s):Array.isArray(t)?e[a]=[...t]:t instanceof Date?e[a]=new Date(t):e[a]=m({},t,s)}else t===void 0&&s?delete e[a]:e[a]=t}return e}function E(e,n,s,a,t,o,r){try{o=F(e,o,t);let l=!o||typeof o=="number"||typeof o=="boolean";if(o===t||!t&&l)return t;let i=t?.nodeType===Node.TEXT_NODE,S=i?t:t?.node;if(l){R(e,t),S?.remove();return}let T=!l&&K(o),u=!l&&U(o),h=!!o&&typeof o!="string"&&!!(o?.node||o?.nodeType===Node.TEXT_NODE);if(!T&&!u&&!h&&!t)throw new Error("Invalid vode: "+typeof o+" "+JSON.stringify(o));if(h&&T?o=o.wholeText:h&&u&&(o=[...o]),i&&T)return S.nodeValue!==o&&(S.nodeValue=o),t;if(T&&(!S||!i)){let y=document.createTextNode(o);if(S)R(e,t),S.replaceWith(y);else{let x=!1;for(let c=a;c<n.childNodes.length;c++){let p=n.childNodes[c];if(p){p.before(y),x=!0;break}}x||n.appendChild(y)}return y}if(u&&(!S||i||t[0]!==o[0])){let y=o;1 in y&&(y[1]=F(e,y[1],void 0));let x=b(o);x?.xmlns!==void 0&&(r=x.xmlns);let c=r?document.createElementNS(r,o[0]):document.createElement(o[0]);if(o.node=c,H(e,c,void 0,x,r??null),x&&"catch"in x&&(o.node.catch=null,o.node.removeAttribute("catch")),S)R(e,t),S.replaceWith(c);else{let d=!1;for(let f=a;f<n.childNodes.length;f++){let g=n.childNodes[f];if(g){g.before(c),d=!0;break}}d||n.appendChild(c)}let p=A(o);if(p>0){let d=x?2:1,f=0;for(let g=0;g<o.length-p;g++){let D=o[g+p],C=E(e,c,g,f,void 0,D,r??null);o[g+d]=C,C&&f++}}return o._unmountCount=(x?.onUnmount?1:0)+V(o),typeof x?.onMount=="function"&&e.patch(x.onMount(e,c)),o}if(!i&&u&&t[0]===o[0]){o.node=S;let y=b(o),x=b(t);y?.xmlns!==void 0&&(r=y.xmlns),H(e,S,x,y,r),y?.catch&&x?.catch!==y.catch&&(o.node.catch=null,o.node.removeAttribute("catch"));let c=A(o),p=A(t);if(c>0){let d=0;for(let f=0;f<o.length-c;f++){let g=o[f+c],D=p>0?t[f+p]:void 0,C=E(e,S,f,d,D,g,r);o[f+c]=C,C&&d++}}if(p>0){let d=c>0?o.length-c:0;for(let f=t.length-1-p;f>=d;f--)E(e,S,f,f,t[f+p],void 0,r)}return o._unmountCount=(y?.onUnmount?1:0)+V(o),o}}catch(l){let i=b(o)?.catch;if(i){let S=typeof i=="function"?i(e,l):i;return E(e,n,s,a,v(o?.node||t?.node,!0),S,r)}else throw l}}function R(e,n){if(!n||!Array.isArray(n)||(n._unmountCount|0)===0)return;let s=L(n);if(s)for(let t=s.length-1;t>=0;t--)R(e,s[t]);let a=b(n);typeof a?.onUnmount=="function"&&e.patch(a.onUnmount(e,n.node))}function V(e){let n=L(e);if(!n)return 0;let s=0;for(let a of n)a&&Array.isArray(a)&&(s+=a._unmountCount|0);return s}function U(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 F(e,n,s){for(;typeof n=="function"&&!n.__memo;)n=n(e);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 o=!0;for(let r=0;r<a.length;r++)if(a[r]!==t[r]){o=!1;break}if(o)return s}for(;typeof n=="function";)n=n(e);return typeof n=="object"&&(n.__memo=a),n}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]=M(e,n,r,l,i,o):M(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]=M(e,n,r,void 0,l,o)}}else if(a)for(let r in a){let l=a[r];a[r]=M(e,n,r,void 0,l,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 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",G(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 G(e){return typeof e=="string"?e:Array.isArray(e)?e.map(G).join(" "):typeof e=="object"?Object.keys(e).filter(n=>e[n]).join(" "):""}var z="a",Z="abbr",tt="address",et="area",nt="article",ot="aside",at="audio",st="b",rt="base",ct="bdi",it="bdo",St="blockquote",lt="body",ft="br",pt="button",ut="canvas",dt="caption",Tt="cite",yt="code",xt="col",gt="colgroup",ht="data",mt="datalist",bt="dd",Pt="del",Et="details",At="dfn",Ct="dialog",Mt="div",Rt="dl",Nt="dt",Ot="em",Dt="embed",vt="fieldset",Lt="figcaption",It="figure",Vt="footer",Ft="form",Ht="h1",Gt="h2",jt="h3",_t="h4",kt="h5",Ut="h6",Kt="head",Bt="header",wt="hgroup",qt="hr",Xt="html",Yt="i",Wt="iframe",$t="img",Jt="input",Qt="ins",zt="kbd",Zt="label",te="legend",ee="li",ne="link",oe="main",ae="map",se="mark",re="menu",ce="meta",ie="meter",Se="nav",le="noscript",fe="object",pe="ol",ue="optgroup",de="option",Te="output",ye="p",xe="picture",ge="pre",he="progress",me="q",be="rp",Pe="rt",Ee="ruby",Ae="s",Ce="samp",Me="script",Re="search",Ne="section",Oe="select",De="slot",ve="small",Le="source",Ie="span",Ve="strong",Fe="style",He="sub",Ge="summary",je="sup",_e="table",ke="tbody",Ue="td",Ke="template",Be="textarea",we="tfoot",qe="th",Xe="thead",Ye="time",We="title",$e="tr",Je="track",Qe="u",ze="ul",Ze="var",tn="video",en="wbr",nn="animate",on="animateMotion",an="animateTransform",sn="circle",rn="clipPath",cn="defs",Sn="desc",ln="ellipse",fn="feBlend",pn="feColorMatrix",un="feComponentTransfer",dn="feComposite",Tn="feConvolveMatrix",yn="feDiffuseLighting",xn="feDisplacementMap",gn="feDistantLight",hn="feDropShadow",mn="feFlood",bn="feFuncA",Pn="feFuncB",En="feFuncG",An="feFuncR",Cn="feGaussianBlur",Mn="feImage",Rn="feMerge",Nn="feMergeNode",On="feMorphology",Dn="feOffset",vn="fePointLight",Ln="feSpecularLighting",In="feSpotLight",Vn="feTile",Fn="feTurbulence",Hn="filter",Gn="foreignObject",jn="g",_n="image",kn="line",Un="linearGradient",Kn="marker",Bn="mask",wn="metadata",qn="mpath",Xn="path",Yn="pattern",Wn="polygon",$n="polyline",Jn="radialGradient",Qn="rect",zn="set",Zn="stop",to="svg",eo="switch",no="symbol",oo="text",ao="textPath",so="tspan",ro="use",co="view",io="annotation",So="annotation-xml",lo="maction",fo="math",po="merror",uo="mfrac",To="mi",yo="mmultiscripts",xo="mn",go="mo",ho="mover",mo="mpadded",bo="mphantom",Po="mprescripts",Eo="mroot",Ao="mrow",Co="ms",Mo="mspace",Ro="msqrt",No="mstyle",Oo="msub",Do="msubsup",vo="msup",Lo="mtable",Io="mtd",Vo="mtext",Fo="mtr",Ho="munder",Go="munderover",jo="semantics";function j(...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"&&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 if(typeof a=="object"&&typeof t=="object")n={...a,...t};else throw new Error(`cannot merge classes of ${a} (${typeof a}) and ${t} (${typeof t})`);else continue}return n}var N;function _(...e){N||(N=document.createElement("div"));try{let n=N.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{N.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=_(n.style,s.style):a==="class"?n.class=j(n.class,s.class):n[a]=s[a]}return n}function Xo(e,n){if(n){let a=n(k(e,[])).___KeYs___;return new O(e,a)}return new O(e,[])}var O=class e{constructor(n,s){this.state=n;this.keys=s;function a(i,S){if(s.length>1){let T=0,u=S[s[T]];for((typeof u!="object"||u===null)&&(S[s[T]]=u={}),T=1;T<s.length-1;T++){let h=u;u=u[s[T]],(typeof u!="object"||u===null)&&(h[s[T]]=u={})}u[s[T]]=i}else s.length===1?typeof S[s[0]]=="object"&&typeof i=="object"&&i!==null?Object.assign(S[s[0]],i):S[s[0]]=i:Object.assign(S,i)}function t(i){let S={};return a(i,S),S}function o(){if(s.length===0)return n;let i=n?n[s[0]]:void 0;for(let S=1;S<s.length&&i;S++)i=i[s[S]];return i}function r(i){a(i,n)}function l(i,S){S?n.patch([t(i)]):n.patch(t(i))}return new Proxy(this,{get:(i,S,T)=>{if(S==="get")return o;if(S==="put")return r;if(S==="patch")return l;let u=[...s,String(S)];return new e(i.state,u)},set:(i,S,T,u)=>{throw new Error("ProxyStateContext is not meant to be directly mutated. Use put() or patch() methods on the StateContext instead")}})}state;keys;get(){}put(n){}patch(n){}};function k(e,n){return new Proxy(e,{get:(s,a,t)=>{if(a==="___KeYs___")return n;let o=[...n,String(a)];return k(e,o)},set:(s,a,t,o)=>{throw new Error("ProxyState is not meant to be directly mutated")}})}export{z as A,Z as ABBR,tt as ADDRESS,nn as ANIMATE,on as ANIMATEMOTION,an as ANIMATETRANSFORM,io as ANNOTATION,So as ANNOTATION_XML,et as AREA,nt as ARTICLE,ot as ASIDE,at as AUDIO,st as B,rt as BASE,ct as BDI,it as BDO,St as BLOCKQUOTE,lt as BODY,ft as BR,pt as BUTTON,ut as CANVAS,dt as CAPTION,sn as CIRCLE,Tt as CITE,rn as CLIPPATH,yt as CODE,xt as COL,gt as COLGROUP,ht as DATA,mt as DATALIST,bt as DD,cn as DEFS,Pt as DEL,Sn as DESC,Et as DETAILS,At as DFN,Ct as DIALOG,Mt as DIV,Rt as DL,Nt as DT,ln as ELLIPSE,Ot as EM,Dt as EMBED,fn as FEBLEND,pn as FECOLORMATRIX,un as FECOMPONENTTRANSFER,dn as FECOMPOSITE,Tn as FECONVOLVEMATRIX,yn as FEDIFFUSELIGHTING,xn as FEDISPLACEMENTMAP,gn as FEDISTANTLIGHT,hn as FEDROPSHADOW,mn as FEFLOOD,bn as FEFUNCA,Pn as FEFUNCB,En as FEFUNCG,An as FEFUNCR,Cn as FEGAUSSIANBLUR,Mn as FEIMAGE,Rn as FEMERGE,Nn as FEMERGENODE,On as FEMORPHOLOGY,Dn as FEOFFSET,vn as FEPOINTLIGHT,Ln as FESPECULARLIGHTING,In as FESPOTLIGHT,Vn as FETILE,Fn as FETURBULENCE,vt as FIELDSET,Lt as FIGCAPTION,It as FIGURE,Hn as FILTER,Vt as FOOTER,Gn as FOREIGNOBJECT,Ft as FORM,jn as G,Ht as H1,Gt as H2,jt as H3,_t as H4,kt as H5,Ut as H6,Kt as HEAD,Bt as HEADER,wt as HGROUP,qt as HR,Xt as HTML,Yt as I,Wt as IFRAME,_n as IMAGE,$t as IMG,Jt as INPUT,Qt as INS,zt as KBD,Zt as LABEL,te as LEGEND,ee as LI,kn as LINE,Un as LINEARGRADIENT,ne as LINK,lo as MACTION,oe as MAIN,ae as MAP,se as MARK,Kn as MARKER,Bn as MASK,fo as MATH,re as MENU,po as MERROR,ce as META,wn as METADATA,ie as METER,uo as MFRAC,To as MI,yo as MMULTISCRIPTS,xo as MN,go as MO,ho as MOVER,mo as MPADDED,qn as MPATH,bo as MPHANTOM,Po as MPRESCRIPTS,Eo as MROOT,Ao as MROW,Co as MS,Mo as MSPACE,Ro as MSQRT,No as MSTYLE,Oo as MSUB,Do as MSUBSUP,vo as MSUP,Lo as MTABLE,Io as MTD,Vo as MTEXT,Fo as MTR,Ho as MUNDER,Go as MUNDEROVER,Se as NAV,le as NOSCRIPT,fe as OBJECT,pe as OL,ue as OPTGROUP,de as OPTION,Te as OUTPUT,ye as P,Xn as PATH,Yn as PATTERN,xe as PICTURE,Wn as POLYGON,$n as POLYLINE,ge as PRE,he as PROGRESS,me as Q,Jn as RADIALGRADIENT,Qn as RECT,be as RP,Pe as RT,Ee as RUBY,Ae as S,Ce as SAMP,Me as SCRIPT,Re as SEARCH,Ne as SECTION,Oe as SELECT,jo as SEMANTICS,zn as SET,De as SLOT,ve as SMALL,Le as SOURCE,Ie as SPAN,Zn as STOP,Ve as STRONG,Fe as STYLE,He as SUB,Ge as SUMMARY,je as SUP,to as SVG,eo as SWITCH,no as SYMBOL,_e as TABLE,ke as TBODY,Ue as TD,Ke as TEMPLATE,oo as TEXT,Be as TEXTAREA,ao as TEXTPATH,we as TFOOT,qe as TH,Xe as THEAD,Ye as TIME,We as TITLE,$e as TR,Je as TRACK,so as TSPAN,Qe as U,ze as UL,ro as USE,Ze as VAR,tn as VIDEO,co as VIEW,en as WBR,w as app,J as child,$ as childCount,L as children,A as childrenStart,Xo as context,Y as createPatch,X as createState,I as defuse,P as globals,v as hydrate,q as memo,j as mergeClass,wo as mergeProps,_ as mergeStyle,b as props,W as tag,B as vode};
|
package/dist/vode.mjs
CHANGED
|
@@ -96,9 +96,8 @@ function app(container, state, dom, ...initialPatches) {
|
|
|
96
96
|
});
|
|
97
97
|
function renderDom(isAnimated) {
|
|
98
98
|
const sw = performance.now();
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (container.tagName.toUpperCase() !== vom[0].toUpperCase()) {
|
|
99
|
+
_vode.vode = render(_vode.state, container.parentElement, 0, 0, _vode.vode, dom(_vode.state));
|
|
100
|
+
if (container.tagName.toLowerCase() !== _vode.vode[0].toLowerCase()) {
|
|
102
101
|
container = _vode.vode.node;
|
|
103
102
|
container._vode = _vode;
|
|
104
103
|
}
|
|
@@ -160,6 +159,10 @@ function app(container, state, dom, ...initialPatches) {
|
|
|
160
159
|
hydrate(container, true),
|
|
161
160
|
dom(state)
|
|
162
161
|
);
|
|
162
|
+
if (container.tagName.toLowerCase() !== _vode.vode[0].toLowerCase()) {
|
|
163
|
+
container = _vode.vode.node;
|
|
164
|
+
container._vode = _vode;
|
|
165
|
+
}
|
|
163
166
|
const continueRendering = _vode.stats.syncRenderPatchCount !== patchCountBefore;
|
|
164
167
|
_vode.isRendering = 0;
|
|
165
168
|
_vode.stats.syncRenderCount++;
|
|
@@ -933,7 +936,12 @@ function mergeProps(...props2) {
|
|
|
933
936
|
}
|
|
934
937
|
|
|
935
938
|
// src/state-context.ts
|
|
936
|
-
function context(state) {
|
|
939
|
+
function context(state, producePath) {
|
|
940
|
+
if (producePath) {
|
|
941
|
+
const proxy = producePath(proxyState(state, []));
|
|
942
|
+
const keys = proxy["___KeYs___"];
|
|
943
|
+
return new ProxyStateContextImpl(state, keys);
|
|
944
|
+
}
|
|
937
945
|
return new ProxyStateContextImpl(state, []);
|
|
938
946
|
}
|
|
939
947
|
var ProxyStateContextImpl = class _ProxyStateContextImpl {
|
|
@@ -991,16 +999,17 @@ var ProxyStateContextImpl = class _ProxyStateContextImpl {
|
|
|
991
999
|
}
|
|
992
1000
|
return new Proxy(this, {
|
|
993
1001
|
get: (target, prop, receiver) => {
|
|
994
|
-
if (prop === "state")
|
|
995
|
-
return state;
|
|
996
1002
|
if (prop === "get")
|
|
997
1003
|
return get;
|
|
998
1004
|
if (prop === "put")
|
|
999
1005
|
return put;
|
|
1000
1006
|
if (prop === "patch")
|
|
1001
1007
|
return patch;
|
|
1002
|
-
const newKeys = [...
|
|
1008
|
+
const newKeys = [...keys, String(prop)];
|
|
1003
1009
|
return new _ProxyStateContextImpl(target.state, newKeys);
|
|
1010
|
+
},
|
|
1011
|
+
set: (target, p, newValue, receiver) => {
|
|
1012
|
+
throw new Error("ProxyStateContext is not meant to be directly mutated. Use put() or patch() methods on the StateContext instead");
|
|
1004
1013
|
}
|
|
1005
1014
|
});
|
|
1006
1015
|
}
|
|
@@ -1014,6 +1023,20 @@ var ProxyStateContextImpl = class _ProxyStateContextImpl {
|
|
|
1014
1023
|
patch(value) {
|
|
1015
1024
|
}
|
|
1016
1025
|
};
|
|
1026
|
+
function proxyState(state, keys) {
|
|
1027
|
+
return new Proxy(state, {
|
|
1028
|
+
get: (target, prop, receiver) => {
|
|
1029
|
+
if (prop === "___KeYs___") {
|
|
1030
|
+
return keys;
|
|
1031
|
+
}
|
|
1032
|
+
const newKeys = [...keys, String(prop)];
|
|
1033
|
+
return proxyState(state, newKeys);
|
|
1034
|
+
},
|
|
1035
|
+
set: (target, p, newValue, receiver) => {
|
|
1036
|
+
throw new Error("ProxyState is not meant to be directly mutated");
|
|
1037
|
+
}
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1017
1040
|
export {
|
|
1018
1041
|
A,
|
|
1019
1042
|
ABBR,
|
package/dist/vode.tests.mjs
CHANGED
|
@@ -96,9 +96,8 @@ function app(container, state, dom, ...initialPatches) {
|
|
|
96
96
|
});
|
|
97
97
|
function renderDom(isAnimated) {
|
|
98
98
|
const sw = performance.now();
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (container.tagName.toUpperCase() !== vom[0].toUpperCase()) {
|
|
99
|
+
_vode.vode = render(_vode.state, container.parentElement, 0, 0, _vode.vode, dom(_vode.state));
|
|
100
|
+
if (container.tagName.toLowerCase() !== _vode.vode[0].toLowerCase()) {
|
|
102
101
|
container = _vode.vode.node;
|
|
103
102
|
container._vode = _vode;
|
|
104
103
|
}
|
|
@@ -160,6 +159,10 @@ function app(container, state, dom, ...initialPatches) {
|
|
|
160
159
|
hydrate(container, true),
|
|
161
160
|
dom(state)
|
|
162
161
|
);
|
|
162
|
+
if (container.tagName.toLowerCase() !== _vode.vode[0].toLowerCase()) {
|
|
163
|
+
container = _vode.vode.node;
|
|
164
|
+
container._vode = _vode;
|
|
165
|
+
}
|
|
163
166
|
const continueRendering = _vode.stats.syncRenderPatchCount !== patchCountBefore;
|
|
164
167
|
_vode.isRendering = 0;
|
|
165
168
|
_vode.stats.syncRenderCount++;
|
|
@@ -755,7 +758,12 @@ function mergeProps(...props2) {
|
|
|
755
758
|
}
|
|
756
759
|
|
|
757
760
|
// src/state-context.ts
|
|
758
|
-
function context(state) {
|
|
761
|
+
function context(state, producePath) {
|
|
762
|
+
if (producePath) {
|
|
763
|
+
const proxy = producePath(proxyState(state, []));
|
|
764
|
+
const keys = proxy["___KeYs___"];
|
|
765
|
+
return new ProxyStateContextImpl(state, keys);
|
|
766
|
+
}
|
|
759
767
|
return new ProxyStateContextImpl(state, []);
|
|
760
768
|
}
|
|
761
769
|
var ProxyStateContextImpl = class _ProxyStateContextImpl {
|
|
@@ -813,16 +821,17 @@ var ProxyStateContextImpl = class _ProxyStateContextImpl {
|
|
|
813
821
|
}
|
|
814
822
|
return new Proxy(this, {
|
|
815
823
|
get: (target, prop, receiver) => {
|
|
816
|
-
if (prop === "state")
|
|
817
|
-
return state;
|
|
818
824
|
if (prop === "get")
|
|
819
825
|
return get;
|
|
820
826
|
if (prop === "put")
|
|
821
827
|
return put;
|
|
822
828
|
if (prop === "patch")
|
|
823
829
|
return patch;
|
|
824
|
-
const newKeys = [...
|
|
830
|
+
const newKeys = [...keys, String(prop)];
|
|
825
831
|
return new _ProxyStateContextImpl(target.state, newKeys);
|
|
832
|
+
},
|
|
833
|
+
set: (target, p, newValue, receiver) => {
|
|
834
|
+
throw new Error("ProxyStateContext is not meant to be directly mutated. Use put() or patch() methods on the StateContext instead");
|
|
826
835
|
}
|
|
827
836
|
});
|
|
828
837
|
}
|
|
@@ -836,6 +845,20 @@ var ProxyStateContextImpl = class _ProxyStateContextImpl {
|
|
|
836
845
|
patch(value) {
|
|
837
846
|
}
|
|
838
847
|
};
|
|
848
|
+
function proxyState(state, keys) {
|
|
849
|
+
return new Proxy(state, {
|
|
850
|
+
get: (target, prop, receiver) => {
|
|
851
|
+
if (prop === "___KeYs___") {
|
|
852
|
+
return keys;
|
|
853
|
+
}
|
|
854
|
+
const newKeys = [...keys, String(prop)];
|
|
855
|
+
return proxyState(state, newKeys);
|
|
856
|
+
},
|
|
857
|
+
set: (target, p, newValue, receiver) => {
|
|
858
|
+
throw new Error("ProxyState is not meant to be directly mutated");
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
}
|
|
839
862
|
|
|
840
863
|
// test/mocks.ts
|
|
841
864
|
var NodeConstants = {
|
|
@@ -1627,8 +1650,7 @@ var tests_app_default = {
|
|
|
1627
1650
|
const state = { a: 1, b: 2 };
|
|
1628
1651
|
app(container, state, () => [DIV]);
|
|
1629
1652
|
await state.patch([{ a: 10 }, { b: 20 }]);
|
|
1630
|
-
await expect(state
|
|
1631
|
-
await expect(state.b).toEqual(20);
|
|
1653
|
+
await expect(state).toEqual({ a: 10, b: 20 });
|
|
1632
1654
|
},
|
|
1633
1655
|
"app(): multiple sequential patches both apply": async () => {
|
|
1634
1656
|
const root = document.createElement("div");
|
|
@@ -2429,45 +2451,40 @@ var tests_mergeProps_default = {
|
|
|
2429
2451
|
|
|
2430
2452
|
// test/tests-state-context.ts
|
|
2431
2453
|
var tests_state_context_default = {
|
|
2432
|
-
"
|
|
2433
|
-
const state = createState({ x: 10 });
|
|
2434
|
-
const ctx = context(state);
|
|
2435
|
-
await expect(ctx.state === state).toEqual(true);
|
|
2436
|
-
},
|
|
2437
|
-
"StateContext.get() returns whole state": async () => {
|
|
2454
|
+
"context(s)...get(): returns whole state": async () => {
|
|
2438
2455
|
const state = createState({ a: 1, b: 2 });
|
|
2439
2456
|
const ctx = context(state);
|
|
2440
2457
|
await expect(ctx.get()).toEqual({ a: 1, b: 2 });
|
|
2441
2458
|
},
|
|
2442
|
-
"
|
|
2459
|
+
"context(s)...get(): deep nested": async () => {
|
|
2443
2460
|
const state = createState({ a: { b: { c: 42 } } });
|
|
2444
2461
|
const ctx = context(state);
|
|
2445
2462
|
await expect(ctx.a.b.c.get()).toEqual(42);
|
|
2446
2463
|
},
|
|
2447
|
-
"
|
|
2464
|
+
"context(s)...get(): missing nested path returns undefined": async () => {
|
|
2448
2465
|
const state = createState({ a: {} });
|
|
2449
2466
|
const ctx = context(state);
|
|
2450
2467
|
await expect(ctx.a.b.get()).toEqual(void 0);
|
|
2451
2468
|
},
|
|
2452
|
-
"
|
|
2469
|
+
"context(s)...put(): silently mutates state": async () => {
|
|
2453
2470
|
const state = createState({ a: { b: 1 } });
|
|
2454
2471
|
const ctx = context(state);
|
|
2455
2472
|
ctx.a.b.put(2);
|
|
2456
2473
|
await expect(state.a.b).toEqual(2);
|
|
2457
2474
|
},
|
|
2458
|
-
"
|
|
2475
|
+
"context(s)...put(): on nested object replaces the sub-object": async () => {
|
|
2459
2476
|
const state = createState({ a: { b: { x: 1, y: 2 } } });
|
|
2460
2477
|
const ctx = context(state);
|
|
2461
2478
|
ctx.a.b.put({ y: 99 });
|
|
2462
2479
|
await expect(state.a.b).toEqual({ y: 99 });
|
|
2463
2480
|
},
|
|
2464
|
-
"
|
|
2481
|
+
"context(s)...put(): at root level with empty keys": async () => {
|
|
2465
2482
|
const state = createState({ a: 1, b: 2 });
|
|
2466
2483
|
const ctx = context(state);
|
|
2467
2484
|
ctx.put({ b: void 0 });
|
|
2468
2485
|
await expect(state).toEqual({ a: 1 });
|
|
2469
2486
|
},
|
|
2470
|
-
"
|
|
2487
|
+
"context(s)...patch(): calls state.patch with proper deep partial": async () => {
|
|
2471
2488
|
const state = createState({ a: { b: 1 } });
|
|
2472
2489
|
const ctx = context(state);
|
|
2473
2490
|
ctx.a.b.patch(2);
|
|
@@ -2475,7 +2492,7 @@ var tests_state_context_default = {
|
|
|
2475
2492
|
await expect(patches.length).toEqual(1);
|
|
2476
2493
|
await expect(patches[0]).toEqual({ a: { b: 2 } });
|
|
2477
2494
|
},
|
|
2478
|
-
"
|
|
2495
|
+
"context(s)...patch(): async wraps in array": async () => {
|
|
2479
2496
|
const state = createState({ a: { b: 1 } });
|
|
2480
2497
|
const ctx = context(state);
|
|
2481
2498
|
ctx.a.b.patch(2, true);
|
|
@@ -2484,7 +2501,7 @@ var tests_state_context_default = {
|
|
|
2484
2501
|
await expect(Array.isArray(patches[0])).toEqual(true);
|
|
2485
2502
|
await expect(patches[0][0]).toEqual({ a: { b: 2 } });
|
|
2486
2503
|
},
|
|
2487
|
-
"
|
|
2504
|
+
"context(s)...patch(): on nested deep path three levels": async () => {
|
|
2488
2505
|
const state = createState({ x: { y: { z: 0 } } });
|
|
2489
2506
|
const ctx = context(state);
|
|
2490
2507
|
ctx.x.y.z.patch(100);
|
|
@@ -2492,7 +2509,7 @@ var tests_state_context_default = {
|
|
|
2492
2509
|
await expect(patches.length).toEqual(1);
|
|
2493
2510
|
await expect(patches[0]).toEqual({ x: { y: { z: 100 } } });
|
|
2494
2511
|
},
|
|
2495
|
-
"
|
|
2512
|
+
"context(s)...put(): with intermediate null creates objects along the path": async () => {
|
|
2496
2513
|
const state = createState({ a: null });
|
|
2497
2514
|
const ctx = context(state);
|
|
2498
2515
|
ctx.a.b.put(42);
|
|
@@ -2501,24 +2518,133 @@ var tests_state_context_default = {
|
|
|
2501
2518
|
await expect(state.a).toEqual(null);
|
|
2502
2519
|
await expect(state.a?.b).toEqual(void 0);
|
|
2503
2520
|
},
|
|
2504
|
-
"
|
|
2521
|
+
"context(s)...put(): with three-level intermediate null": async () => {
|
|
2505
2522
|
const state = createState({ a: null });
|
|
2506
2523
|
const ctx = context(state);
|
|
2507
2524
|
ctx.a.b.c.put(99);
|
|
2508
2525
|
await expect(state.a?.b.c).toEqual(99);
|
|
2509
2526
|
},
|
|
2510
|
-
"
|
|
2527
|
+
"context(s)...put(): with multiple intermediate nulls": async () => {
|
|
2511
2528
|
const state = createState({ a: { x: null, y: 1 } });
|
|
2512
2529
|
const ctx = context(state);
|
|
2513
2530
|
ctx.a.x.z.put("deep");
|
|
2514
2531
|
await expect(state.a.x?.z).toEqual("deep");
|
|
2515
2532
|
await expect(state.a.y).toEqual(1);
|
|
2516
2533
|
},
|
|
2517
|
-
"
|
|
2534
|
+
"context(s)...put(): merges into existing object properties via Object.assign": async () => {
|
|
2518
2535
|
const state = createState({ items: { count: 0, name: "test", hidden: false } });
|
|
2519
2536
|
const ctx = context(state);
|
|
2520
2537
|
ctx.items.put({ count: 5 });
|
|
2521
2538
|
await expect(state.items).toEqual({ count: 5, name: "test", hidden: false });
|
|
2539
|
+
},
|
|
2540
|
+
"context(state, s => s).get(): returns whole state": async () => {
|
|
2541
|
+
const state = createState({ a: 1, b: 2 });
|
|
2542
|
+
const ctx = context(state, (s) => s);
|
|
2543
|
+
await expect(ctx.get()).toEqual({ a: 1, b: 2 });
|
|
2544
|
+
},
|
|
2545
|
+
"context(state, s => s.a.b.c).get(): deep nested": async () => {
|
|
2546
|
+
const state = createState({ a: { b: { c: 42 } } });
|
|
2547
|
+
const ctx = context(state, (s) => s.a.b.c);
|
|
2548
|
+
await expect(ctx.get()).toEqual(42);
|
|
2549
|
+
},
|
|
2550
|
+
"context(state, s => s.a.b).get(): missing nested path returns undefined": async () => {
|
|
2551
|
+
const state = createState({ a: {} });
|
|
2552
|
+
const ctx = context(state, (s) => s.a.b);
|
|
2553
|
+
await expect(ctx.get()).toEqual(void 0);
|
|
2554
|
+
},
|
|
2555
|
+
"context(state, s => s.a.b).put(): silently mutates state": async () => {
|
|
2556
|
+
const state = createState({ a: { b: 1 } });
|
|
2557
|
+
const ctx = context(state, (s) => s.a.b);
|
|
2558
|
+
ctx.put(2);
|
|
2559
|
+
await expect(state.a.b).toEqual(2);
|
|
2560
|
+
},
|
|
2561
|
+
"context(state, s => s.a.b).put(): on nested object replaces the sub-object": async () => {
|
|
2562
|
+
const state = createState({ a: { b: { x: 1, y: 2 } } });
|
|
2563
|
+
const ctx = context(state, (s) => s.a.b);
|
|
2564
|
+
ctx.put({ y: 99 });
|
|
2565
|
+
await expect(state.a.b).toEqual({ y: 99 });
|
|
2566
|
+
},
|
|
2567
|
+
"context(state, s => s).put(): at root level with empty keys": async () => {
|
|
2568
|
+
const state = createState({ a: 1, b: 2 });
|
|
2569
|
+
const ctx = context(state, (s) => s);
|
|
2570
|
+
ctx.put({ b: void 0 });
|
|
2571
|
+
await expect(state).toEqual({ a: 1 });
|
|
2572
|
+
},
|
|
2573
|
+
"context(state, s => s.a.b).patch(): calls state.patch with proper deep partial": async () => {
|
|
2574
|
+
const state = createState({ a: { b: 1 } });
|
|
2575
|
+
const ctx = context(state, (s) => s.a.b);
|
|
2576
|
+
ctx.patch(2);
|
|
2577
|
+
const patches = state.patch.initialPatches;
|
|
2578
|
+
await expect(patches.length).toEqual(1);
|
|
2579
|
+
await expect(patches[0]).toEqual({ a: { b: 2 } });
|
|
2580
|
+
},
|
|
2581
|
+
"context(state, s => s.a.b).patch(): async wraps in array": async () => {
|
|
2582
|
+
const state = createState({ a: { b: 1 } });
|
|
2583
|
+
const ctx = context(state, (s) => s.a.b);
|
|
2584
|
+
ctx.patch(2, true);
|
|
2585
|
+
const patches = state.patch.initialPatches;
|
|
2586
|
+
await expect(patches.length).toEqual(1);
|
|
2587
|
+
await expect(Array.isArray(patches[0])).toEqual(true);
|
|
2588
|
+
await expect(patches[0][0]).toEqual({ a: { b: 2 } });
|
|
2589
|
+
},
|
|
2590
|
+
"context(state, s => s.x.y.z).patch(): on nested deep path three levels": async () => {
|
|
2591
|
+
const state = createState({ x: { y: { z: 0 } } });
|
|
2592
|
+
const ctx = context(state, (s) => s.x.y.z);
|
|
2593
|
+
ctx.patch(100);
|
|
2594
|
+
const patches = state.patch.initialPatches;
|
|
2595
|
+
await expect(patches.length).toEqual(1);
|
|
2596
|
+
await expect(patches[0]).toEqual({ x: { y: { z: 100 } } });
|
|
2597
|
+
},
|
|
2598
|
+
"context(state, s => s.x).y.z: continue proxy sub-state targeting": async () => {
|
|
2599
|
+
const state = createState({ x: { y: { z: 0 } } });
|
|
2600
|
+
const ctx = context(state, (s) => s.x).y.z;
|
|
2601
|
+
ctx.patch(100);
|
|
2602
|
+
const patches = state.patch.initialPatches;
|
|
2603
|
+
await expect(patches.length).toEqual(1);
|
|
2604
|
+
await expect(patches[0]).toEqual({ x: { y: { z: 100 } } });
|
|
2605
|
+
},
|
|
2606
|
+
"context(state, s => s.a.b).put(): with intermediate null creates objects": async () => {
|
|
2607
|
+
const state = createState({ a: null });
|
|
2608
|
+
const ctx = context(state, (s) => s.a.b);
|
|
2609
|
+
ctx.put(42);
|
|
2610
|
+
await expect(state.a?.b).toEqual(42);
|
|
2611
|
+
},
|
|
2612
|
+
"context(state, s => s.a.b.c).put(): with three-level intermediate null": async () => {
|
|
2613
|
+
const state = createState({ a: null });
|
|
2614
|
+
const ctx = context(state, (s) => s.a.b.c);
|
|
2615
|
+
ctx.put(99);
|
|
2616
|
+
await expect(state.a?.b.c).toEqual(99);
|
|
2617
|
+
},
|
|
2618
|
+
"context(state, s => s.a.x.z).put(): with multiple intermediate nulls": async () => {
|
|
2619
|
+
const state = createState({ a: { x: null, y: 1 } });
|
|
2620
|
+
const ctx = context(state, (s) => s.a.x.z);
|
|
2621
|
+
ctx.put("deep");
|
|
2622
|
+
await expect(state.a.x?.z).toEqual("deep");
|
|
2623
|
+
await expect(state.a.y).toEqual(1);
|
|
2624
|
+
},
|
|
2625
|
+
"context(state, s => s.items).put(): merges into existing object properties via Object.assign": async () => {
|
|
2626
|
+
const state = createState({ items: { count: 0, name: "test", hidden: false } });
|
|
2627
|
+
const ctx = context(state, (s) => s.items);
|
|
2628
|
+
ctx.put({ count: 5 });
|
|
2629
|
+
await expect(state.items).toEqual({ count: 5, name: "test", hidden: false });
|
|
2630
|
+
},
|
|
2631
|
+
"context(state, s => s.get|put|patch...): 'get','put','patch' as intermediate properties without conflict": async () => {
|
|
2632
|
+
const state = createState({
|
|
2633
|
+
endpoints: {
|
|
2634
|
+
get: { count: 1 },
|
|
2635
|
+
put: { count: 2 },
|
|
2636
|
+
patch: { count: 3 }
|
|
2637
|
+
}
|
|
2638
|
+
});
|
|
2639
|
+
const getCtx = context(state, (s) => s.endpoints.get);
|
|
2640
|
+
await expect(getCtx.get()).toEqual({ count: 1 });
|
|
2641
|
+
const putCtx = context(state, (s) => s.endpoints.put);
|
|
2642
|
+
putCtx.put({ count: 99 });
|
|
2643
|
+
await expect(state.endpoints.put).toEqual({ count: 99 });
|
|
2644
|
+
const patchCtx = context(state, (s) => s.endpoints.patch);
|
|
2645
|
+
patchCtx.patch({ count: 42 });
|
|
2646
|
+
const patches = state.patch.initialPatches;
|
|
2647
|
+
await expect(patches[0]).toEqual({ endpoints: { patch: { count: 42 } } });
|
|
2522
2648
|
}
|
|
2523
2649
|
};
|
|
2524
2650
|
|
|
@@ -5298,6 +5424,66 @@ var tests_catch_default = {
|
|
|
5298
5424
|
[ARTICLE, "i am fine"]
|
|
5299
5425
|
]
|
|
5300
5426
|
);
|
|
5427
|
+
},
|
|
5428
|
+
"catch: bubbles up to the root component if deeply nested vodes dont catch it earlier": async () => {
|
|
5429
|
+
const root = document.createElement("div");
|
|
5430
|
+
const container = document.createElement("div");
|
|
5431
|
+
root.appendChild(container);
|
|
5432
|
+
app(
|
|
5433
|
+
container,
|
|
5434
|
+
{},
|
|
5435
|
+
() => [
|
|
5436
|
+
DIV,
|
|
5437
|
+
{
|
|
5438
|
+
catch: (s, err) => [DIV, `caught: ${err.message}`]
|
|
5439
|
+
},
|
|
5440
|
+
[
|
|
5441
|
+
MAIN,
|
|
5442
|
+
[
|
|
5443
|
+
SECTION,
|
|
5444
|
+
[ARTICLE, {
|
|
5445
|
+
onMount: () => {
|
|
5446
|
+
throw new Error("boom");
|
|
5447
|
+
}
|
|
5448
|
+
}]
|
|
5449
|
+
]
|
|
5450
|
+
]
|
|
5451
|
+
]
|
|
5452
|
+
);
|
|
5453
|
+
await expect(container).toMatch(
|
|
5454
|
+
[DIV, "caught: boom"]
|
|
5455
|
+
);
|
|
5456
|
+
},
|
|
5457
|
+
"catch: if catching in root vode with different Tag -> container will be replaced": async () => {
|
|
5458
|
+
const root = document.createElement("div");
|
|
5459
|
+
const container = document.createElement("div");
|
|
5460
|
+
root.appendChild(container);
|
|
5461
|
+
await expect(root.firstChild === container).toEqual(true);
|
|
5462
|
+
app(
|
|
5463
|
+
container,
|
|
5464
|
+
{},
|
|
5465
|
+
() => [
|
|
5466
|
+
DIV,
|
|
5467
|
+
{
|
|
5468
|
+
catch: (s, err) => [P, `caught: ${err.message}`]
|
|
5469
|
+
},
|
|
5470
|
+
[
|
|
5471
|
+
MAIN,
|
|
5472
|
+
[
|
|
5473
|
+
SECTION,
|
|
5474
|
+
[ARTICLE, {
|
|
5475
|
+
onMount: () => {
|
|
5476
|
+
throw new Error("boom");
|
|
5477
|
+
}
|
|
5478
|
+
}]
|
|
5479
|
+
]
|
|
5480
|
+
]
|
|
5481
|
+
]
|
|
5482
|
+
);
|
|
5483
|
+
await expect(root.firstChild === container).toEqual(false);
|
|
5484
|
+
await expect(root.firstChild).toMatch(
|
|
5485
|
+
[P, "caught: boom"]
|
|
5486
|
+
);
|
|
5301
5487
|
}
|
|
5302
5488
|
};
|
|
5303
5489
|
|
|
@@ -5345,27 +5531,25 @@ var tests_patch_advanced_default = {
|
|
|
5345
5531
|
const container = setup4();
|
|
5346
5532
|
const state = createState({ msg: "before" });
|
|
5347
5533
|
app(container, state, (s) => [DIV, s.msg]);
|
|
5348
|
-
state.patch(Promise.resolve({ msg: "after" }));
|
|
5349
|
-
await
|
|
5350
|
-
await expect(state.msg).toEqual("after");
|
|
5534
|
+
await state.patch(Promise.resolve({ msg: "after" }));
|
|
5535
|
+
await expect(state).toEqual({ msg: "after" });
|
|
5351
5536
|
await expect(container).toMatch([DIV, "after"]);
|
|
5352
5537
|
},
|
|
5353
5538
|
"patch(): array with empty patches applies nothing": async () => {
|
|
5354
5539
|
const container = setup4();
|
|
5355
5540
|
const state = createState({ x: 1, y: 2 });
|
|
5356
5541
|
app(container, state, (s) => [DIV]);
|
|
5357
|
-
state.patch([{}, {}]);
|
|
5358
|
-
await
|
|
5359
|
-
await expect(state
|
|
5542
|
+
await state.patch([{}, {}]);
|
|
5543
|
+
await delay(10);
|
|
5544
|
+
await expect(state).toEqual({ x: 1, y: 2 });
|
|
5360
5545
|
},
|
|
5361
5546
|
"patch(): array with null/undefined items skips them": async () => {
|
|
5362
5547
|
const container = setup4();
|
|
5363
5548
|
const state = createState({ x: 0, y: 0 });
|
|
5364
5549
|
app(container, state, (s) => [DIV, String(s.x), String(s.y)]);
|
|
5365
5550
|
state.patch([null, { x: 10 }, void 0, { y: 20 }]);
|
|
5366
|
-
await
|
|
5367
|
-
await expect(state.
|
|
5368
|
-
await expect(state.y).toEqual(20);
|
|
5551
|
+
await expect(() => expect(state.x).toEqual(10)).toSucceedAsync();
|
|
5552
|
+
await expect(() => expect(state.y).toEqual(20)).toSucceedAsync();
|
|
5369
5553
|
},
|
|
5370
5554
|
"patch(): returns Promise for generator functions, can be awaited": async () => {
|
|
5371
5555
|
const container = setup4();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryupold/vode",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "a minimalist web framework",
|
|
5
5
|
"author": "Michael Scherbakow (ryupold)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"build-tests": "esbuild test/index.ts --bundle --format=esm --outfile=dist/vode.tests.mjs"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@babel/cli": "7.
|
|
54
|
-
"@babel/core": "7.29.
|
|
55
|
-
"@babel/preset-env": "7.29.
|
|
53
|
+
"@babel/cli": "7.29.7",
|
|
54
|
+
"@babel/core": "7.29.7",
|
|
55
|
+
"@babel/preset-env": "7.29.7",
|
|
56
56
|
"babel-preset-minify": "0.5.2",
|
|
57
57
|
"dts-bundle-generator": "9.5.1",
|
|
58
58
|
"esbuild": "0.28.0",
|