@ryupold/vode 1.6.0 → 1.6.2
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.js +56 -32
- package/dist/vode.min.js +1 -1
- package/dist/vode.min.mjs +1 -1
- package/dist/vode.mjs +56 -32
- package/package.json +1 -1
- package/src/vode.ts +64 -34
package/dist/vode.js
CHANGED
|
@@ -331,7 +331,7 @@ var V = (() => {
|
|
|
331
331
|
function renderDom(isAsync) {
|
|
332
332
|
const sw = Date.now();
|
|
333
333
|
const vom = dom(_vode.state);
|
|
334
|
-
_vode.vode = render(_vode.state, container.parentElement, 0, _vode.vode, vom);
|
|
334
|
+
_vode.vode = render(_vode.state, container.parentElement, 0, 0, _vode.vode, vom);
|
|
335
335
|
if (container.tagName.toUpperCase() !== vom[0].toUpperCase()) {
|
|
336
336
|
container = _vode.vode.node;
|
|
337
337
|
container._vode = _vode;
|
|
@@ -383,10 +383,12 @@ var V = (() => {
|
|
|
383
383
|
_vode.state = patchableState;
|
|
384
384
|
const root = container;
|
|
385
385
|
root._vode = _vode;
|
|
386
|
+
const indexInParent = Array.from(container.parentElement.children).indexOf(container);
|
|
386
387
|
_vode.vode = render(
|
|
387
388
|
state,
|
|
388
389
|
container.parentElement,
|
|
389
|
-
|
|
390
|
+
indexInParent,
|
|
391
|
+
indexInParent,
|
|
390
392
|
hydrate(container, true),
|
|
391
393
|
dom(state)
|
|
392
394
|
);
|
|
@@ -536,7 +538,7 @@ var V = (() => {
|
|
|
536
538
|
}
|
|
537
539
|
return target;
|
|
538
540
|
}
|
|
539
|
-
function render(state, parent, childIndex, oldVode, newVode, xmlns) {
|
|
541
|
+
function render(state, parent, childIndex, indexInParent, oldVode, newVode, xmlns) {
|
|
540
542
|
try {
|
|
541
543
|
newVode = remember(state, newVode, oldVode);
|
|
542
544
|
const isNoVode = !newVode || typeof newVode === "number" || typeof newVode === "boolean";
|
|
@@ -572,9 +574,16 @@ var V = (() => {
|
|
|
572
574
|
oldNode.onUnmount && state.patch(oldNode.onUnmount(oldNode));
|
|
573
575
|
oldNode.replaceWith(text);
|
|
574
576
|
} else {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
577
|
+
let inserted = false;
|
|
578
|
+
for (let i = 0; i < parent.childNodes.length; i++) {
|
|
579
|
+
const nextSibling = parent.childNodes[indexInParent + i];
|
|
580
|
+
if (nextSibling) {
|
|
581
|
+
nextSibling.before(text, nextSibling);
|
|
582
|
+
inserted = true;
|
|
583
|
+
break;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
if (!inserted) {
|
|
578
587
|
parent.appendChild(text);
|
|
579
588
|
}
|
|
580
589
|
}
|
|
@@ -586,10 +595,10 @@ var V = (() => {
|
|
|
586
595
|
newvode[1] = remember(state, newvode[1], void 0);
|
|
587
596
|
}
|
|
588
597
|
const properties = props(newVode);
|
|
589
|
-
|
|
598
|
+
if (properties?.xmlns !== void 0) xmlns = properties.xmlns;
|
|
590
599
|
const newNode = xmlns ? document.createElementNS(xmlns, newVode[0]) : document.createElement(newVode[0]);
|
|
591
600
|
newVode.node = newNode;
|
|
592
|
-
patchProperties(state, newNode, void 0, properties);
|
|
601
|
+
patchProperties(state, newNode, void 0, properties, xmlns);
|
|
593
602
|
if (!!properties && "catch" in properties) {
|
|
594
603
|
newVode.node["catch"] = null;
|
|
595
604
|
newVode.node.removeAttribute("catch");
|
|
@@ -598,18 +607,28 @@ var V = (() => {
|
|
|
598
607
|
oldNode.onUnmount && state.patch(oldNode.onUnmount(oldNode));
|
|
599
608
|
oldNode.replaceWith(newNode);
|
|
600
609
|
} else {
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
610
|
+
let inserted = false;
|
|
611
|
+
for (let i = 0; i < parent.childNodes.length; i++) {
|
|
612
|
+
const nextSibling = parent.childNodes[indexInParent + i];
|
|
613
|
+
if (nextSibling) {
|
|
614
|
+
nextSibling.before(newNode, nextSibling);
|
|
615
|
+
inserted = true;
|
|
616
|
+
break;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
if (!inserted) {
|
|
604
620
|
parent.appendChild(newNode);
|
|
605
621
|
}
|
|
606
622
|
}
|
|
607
|
-
const
|
|
608
|
-
if (
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
623
|
+
const newKids = children(newVode);
|
|
624
|
+
if (newKids) {
|
|
625
|
+
const childOffset = !!properties ? 2 : 1;
|
|
626
|
+
let indexP = 0;
|
|
627
|
+
for (let i = 0; i < newKids.length; i++) {
|
|
628
|
+
const child2 = newKids[i];
|
|
629
|
+
const attached = render(state, newNode, i, indexP, void 0, child2, xmlns);
|
|
630
|
+
newVode[i + childOffset] = attached;
|
|
631
|
+
if (attached) indexP++;
|
|
613
632
|
}
|
|
614
633
|
}
|
|
615
634
|
newNode.onMount && state.patch(newNode.onMount(newNode));
|
|
@@ -620,16 +639,16 @@ var V = (() => {
|
|
|
620
639
|
const newvode = newVode;
|
|
621
640
|
const oldvode = oldVode;
|
|
622
641
|
const properties = props(newVode);
|
|
623
|
-
let hasProps = !!properties;
|
|
624
642
|
const oldProps = props(oldVode);
|
|
643
|
+
if (properties?.xmlns !== void 0) xmlns = properties.xmlns;
|
|
625
644
|
if (newvode[1]?.__memo) {
|
|
626
645
|
const prev = newvode[1];
|
|
627
646
|
newvode[1] = remember(state, newvode[1], oldvode[1]);
|
|
628
647
|
if (prev !== newvode[1]) {
|
|
629
|
-
patchProperties(state, oldNode, oldProps, properties);
|
|
648
|
+
patchProperties(state, oldNode, oldProps, properties, xmlns);
|
|
630
649
|
}
|
|
631
650
|
} else {
|
|
632
|
-
patchProperties(state, oldNode, oldProps, properties);
|
|
651
|
+
patchProperties(state, oldNode, oldProps, properties, xmlns);
|
|
633
652
|
}
|
|
634
653
|
if (!!properties?.catch && oldProps?.catch !== properties.catch) {
|
|
635
654
|
newVode.node["catch"] = null;
|
|
@@ -638,19 +657,20 @@ var V = (() => {
|
|
|
638
657
|
const newKids = children(newVode);
|
|
639
658
|
const oldKids = children(oldVode);
|
|
640
659
|
if (newKids) {
|
|
660
|
+
const childOffset = !!properties ? 2 : 1;
|
|
661
|
+
let indexP = 0;
|
|
641
662
|
for (let i = 0; i < newKids.length; i++) {
|
|
642
663
|
const child2 = newKids[i];
|
|
643
664
|
const oldChild = oldKids && oldKids[i];
|
|
644
|
-
const attached = render(state, oldNode, i, oldChild, child2, xmlns);
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
}
|
|
665
|
+
const attached = render(state, oldNode, i, indexP, oldChild, child2, xmlns);
|
|
666
|
+
newVode[i + childOffset] = attached;
|
|
667
|
+
if (attached) indexP++;
|
|
648
668
|
}
|
|
649
669
|
}
|
|
650
670
|
if (oldKids) {
|
|
651
671
|
const newKidsCount = newKids ? newKids.length : 0;
|
|
652
672
|
for (let i = oldKids.length - 1; i >= newKidsCount; i--) {
|
|
653
|
-
render(state, oldNode, i, oldKids[i], void 0, xmlns);
|
|
673
|
+
render(state, oldNode, i, i, oldKids[i], void 0, xmlns);
|
|
654
674
|
}
|
|
655
675
|
}
|
|
656
676
|
return newVode;
|
|
@@ -663,6 +683,7 @@ var V = (() => {
|
|
|
663
683
|
state,
|
|
664
684
|
parent,
|
|
665
685
|
childIndex,
|
|
686
|
+
indexInParent,
|
|
666
687
|
hydrate(newVode?.node || oldVode?.node, true),
|
|
667
688
|
handledVode,
|
|
668
689
|
xmlns
|
|
@@ -707,15 +728,18 @@ var V = (() => {
|
|
|
707
728
|
return c;
|
|
708
729
|
}
|
|
709
730
|
}
|
|
710
|
-
function patchProperties(s, node, oldProps, newProps) {
|
|
731
|
+
function patchProperties(s, node, oldProps, newProps, xmlns) {
|
|
711
732
|
if (!newProps && !oldProps) return;
|
|
733
|
+
const xmlMode = xmlns !== void 0;
|
|
712
734
|
if (oldProps) {
|
|
713
735
|
for (const key in oldProps) {
|
|
714
736
|
const oldValue = oldProps[key];
|
|
715
737
|
const newValue = newProps?.[key];
|
|
716
738
|
if (oldValue !== newValue) {
|
|
717
|
-
if (newProps)
|
|
718
|
-
|
|
739
|
+
if (newProps)
|
|
740
|
+
newProps[key] = patchProperty(s, node, key, oldValue, newValue, xmlMode);
|
|
741
|
+
else
|
|
742
|
+
patchProperty(s, node, key, oldValue, void 0, xmlMode);
|
|
719
743
|
}
|
|
720
744
|
}
|
|
721
745
|
}
|
|
@@ -723,17 +747,17 @@ var V = (() => {
|
|
|
723
747
|
for (const key in newProps) {
|
|
724
748
|
if (!(key in oldProps)) {
|
|
725
749
|
const newValue = newProps[key];
|
|
726
|
-
newProps[key] = patchProperty(s, node, key, void 0, newValue);
|
|
750
|
+
newProps[key] = patchProperty(s, node, key, void 0, newValue, xmlMode);
|
|
727
751
|
}
|
|
728
752
|
}
|
|
729
753
|
} else if (newProps) {
|
|
730
754
|
for (const key in newProps) {
|
|
731
755
|
const newValue = newProps[key];
|
|
732
|
-
newProps[key] = patchProperty(s, node, key, void 0, newValue);
|
|
756
|
+
newProps[key] = patchProperty(s, node, key, void 0, newValue, xmlMode);
|
|
733
757
|
}
|
|
734
758
|
}
|
|
735
759
|
}
|
|
736
|
-
function patchProperty(s, node, key, oldValue, newValue) {
|
|
760
|
+
function patchProperty(s, node, key, oldValue, newValue, xmlMode) {
|
|
737
761
|
if (key === "style") {
|
|
738
762
|
if (!newValue) {
|
|
739
763
|
node.style.cssText = "";
|
|
@@ -778,7 +802,7 @@ var V = (() => {
|
|
|
778
802
|
node[key] = null;
|
|
779
803
|
}
|
|
780
804
|
} else {
|
|
781
|
-
node[key] = newValue;
|
|
805
|
+
if (!xmlMode) node[key] = newValue;
|
|
782
806
|
if (newValue === void 0 || newValue === null || newValue === false)
|
|
783
807
|
node.removeAttribute(key);
|
|
784
808
|
else
|
package/dist/vode.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var V=(()=>{var O=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var B=(e,o)=>{for(var a in o)O(e,a,{get:o[a],enumerable:!0})},_=(e,o,a,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of G(o))!K.call(e,t)&&t!==a&&O(e,t,{get:()=>o[t],enumerable:!(n=U(o,t))||n.enumerable});return e};var q=e=>_(O({},"__esModule",{value:!0}),e);var Xn={};B(Xn,{A:()=>ot,ABBR:()=>nt,ADDRESS:()=>st,ANIMATE:()=>ro,ANIMATEMOTION:()=>co,ANIMATETRANSFORM:()=>io,ANNOTATION:()=>dn,ANNOTATION_XML:()=>un,AREA:()=>at,ARTICLE:()=>rt,ASIDE:()=>ct,AUDIO:()=>it,B:()=>pt,BASE:()=>lt,BDI:()=>St,BDO:()=>ft,BLOCKQUOTE:()=>dt,BODY:()=>ut,BR:()=>Tt,BUTTON:()=>yt,CANVAS:()=>gt,CAPTION:()=>xt,CIRCLE:()=>po,CITE:()=>ht,CLIPPATH:()=>lo,CODE:()=>mt,COL:()=>Et,COLGROUP:()=>bt,DATA:()=>Pt,DATALIST:()=>At,DD:()=>Ct,DEFS:()=>So,DEL:()=>Mt,DESC:()=>fo,DETAILS:()=>Nt,DFN:()=>Rt,DIALOG:()=>Ot,DIV:()=>Dt,DL:()=>vt,DT:()=>Lt,DelegateStateContext:()=>I,ELLIPSE:()=>uo,EM:()=>It,EMBED:()=>Vt,FEBLEND:()=>To,FECOLORMATRIX:()=>yo,FECOMPONENTTRANSFER:()=>go,FECOMPOSITE:()=>xo,FECONVOLVEMATRIX:()=>ho,FEDIFFUSELIGHTING:()=>mo,FEDISPLACEMENTMAP:()=>Eo,FEDISTANTLIGHT:()=>bo,FEDROPSHADOW:()=>Po,FEFLOOD:()=>Ao,FEFUNCA:()=>Co,FEFUNCB:()=>Mo,FEFUNCG:()=>No,FEFUNCR:()=>Ro,FEGAUSSIANBLUR:()=>Oo,FEIMAGE:()=>Do,FEMERGE:()=>vo,FEMERGENODE:()=>Lo,FEMORPHOLOGY:()=>Io,FEOFFSET:()=>Vo,FEPOINTLIGHT:()=>Fo,FESPECULARLIGHTING:()=>ko,FESPOTLIGHT:()=>jo,FETILE:()=>Ho,FETURBULENCE:()=>Uo,FIELDSET:()=>Ft,FIGCAPTION:()=>kt,FIGURE:()=>jt,FILTER:()=>Go,FOOTER:()=>Ht,FOREIGNOBJECT:()=>Ko,FORM:()=>Ut,G:()=>Bo,H1:()=>Gt,H2:()=>Kt,H3:()=>Bt,H4:()=>_t,H5:()=>qt,H6:()=>Xt,HEAD:()=>$t,HEADER:()=>wt,HGROUP:()=>Yt,HR:()=>Wt,HTML:()=>Jt,I:()=>Qt,IFRAME:()=>zt,IMAGE:()=>_o,IMG:()=>Zt,INPUT:()=>te,INS:()=>ee,KBD:()=>oe,KeyStateContext:()=>L,LABEL:()=>ne,LEGEND:()=>se,LI:()=>ae,LINE:()=>qo,LINEARGRADIENT:()=>Xo,LINK:()=>re,MACTION:()=>Tn,MAIN:()=>ce,MAP:()=>ie,MARK:()=>pe,MARKER:()=>$o,MASK:()=>wo,MATH:()=>yn,MENU:()=>le,MERROR:()=>gn,META:()=>Se,METADATA:()=>Yo,METER:()=>fe,MFRAC:()=>xn,MI:()=>hn,MMULTISCRIPTS:()=>mn,MN:()=>En,MO:()=>bn,MOVER:()=>Pn,MPADDED:()=>An,MPATH:()=>Wo,MPHANTOM:()=>Cn,MPRESCRIPTS:()=>Mn,MROOT:()=>Nn,MROW:()=>Rn,MS:()=>On,MSPACE:()=>Dn,MSQRT:()=>vn,MSTYLE:()=>Ln,MSUB:()=>In,MSUBSUP:()=>Vn,MSUP:()=>Fn,MTABLE:()=>kn,MTD:()=>jn,MTEXT:()=>Hn,MTR:()=>Un,MUNDER:()=>Gn,MUNDEROVER:()=>Kn,NAV:()=>de,NOSCRIPT:()=>ue,OBJECT:()=>Te,OL:()=>ye,OPTGROUP:()=>ge,OPTION:()=>xe,OUTPUT:()=>he,P:()=>me,PATH:()=>Jo,PATTERN:()=>Qo,PICTURE:()=>Ee,POLYGON:()=>zo,POLYLINE:()=>Zo,PRE:()=>be,PROGRESS:()=>Pe,Q:()=>Ae,RADIALGRADIENT:()=>tn,RECT:()=>en,RP:()=>Ce,RT:()=>Me,RUBY:()=>Ne,S:()=>Re,SAMP:()=>Oe,SCRIPT:()=>De,SEARCH:()=>ve,SECTION:()=>Le,SELECT:()=>Ie,SEMANTICS:()=>Bn,SET:()=>on,SLOT:()=>Ve,SMALL:()=>Fe,SOURCE:()=>ke,SPAN:()=>je,STOP:()=>nn,STRONG:()=>He,STYLE:()=>Ue,SUB:()=>Ge,SUMMARY:()=>Ke,SUP:()=>Be,SVG:()=>sn,SWITCH:()=>an,SYMBOL:()=>rn,TABLE:()=>_e,TBODY:()=>qe,TD:()=>Xe,TEMPLATE:()=>$e,TEXT:()=>cn,TEXTAREA:()=>we,TEXTPATH:()=>pn,TFOOT:()=>Ye,TH:()=>We,THEAD:()=>Je,TIME:()=>Qe,TITLE:()=>ze,TR:()=>Ze,TRACK:()=>to,TSPAN:()=>ln,U:()=>eo,UL:()=>oo,USE:()=>Sn,VAR:()=>no,VIDEO:()=>so,VIEW:()=>fn,WBR:()=>ao,app:()=>$,child:()=>Z,childCount:()=>z,children:()=>C,childrenStart:()=>R,createPatch:()=>J,createState:()=>W,defuse:()=>w,globals:()=>h,hydrate:()=>N,memo:()=>Y,mergeClass:()=>_n,mergeStyle:()=>qn,props:()=>m,tag:()=>Q,vode:()=>X});var h={currentViewTransition:void 0,requestAnimationFrame:window.requestAnimationFrame?window.requestAnimationFrame.bind(window):(e=>e()),startViewTransition:document.startViewTransition?document.startViewTransition.bind(document):null};function X(e,o,...a){if(!e)throw new Error("first argument to vode() must be a tag name or a vode");return Array.isArray(e)?e:o?[e,o,...a]:[e,...a]}function $(e,o,a,...n){if(!e?.parentElement)throw new Error("first argument to app() must be a valid HTMLElement inside the <html></html> document");if(!o||typeof o!="object")throw new Error("second argument to app() must be a state object");if(typeof a!="function")throw new Error("third argument to app() must be a function that returns a vode");let t={};t.syncRenderer=h.requestAnimationFrame,t.asyncRenderer=h.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 s=o;Object.defineProperty(o,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async(p,d)=>{if(!(!p||typeof p!="function"&&typeof p!="object"))if(t.stats.patchCount++,p?.next){let l=p;t.stats.liveEffectCount++;try{let f=await l.next();for(;f.done===!1;){t.stats.liveEffectCount++;try{s.patch(f.value,d),f=await l.next()}finally{t.stats.liveEffectCount--}}s.patch(f.value,d)}finally{t.stats.liveEffectCount--}}else if(p.then){t.stats.liveEffectCount++;try{let l=await p;s.patch(l,d)}finally{t.stats.liveEffectCount--}}else if(Array.isArray(p))if(p.length>0)for(let l of p)s.patch(l,!document.hidden&&!!t.asyncRenderer);else{t.qSync=y(t.qSync||{},t.qAsync,!1),t.qAsync=null;try{h.currentViewTransition?.skipTransition()}catch{}t.stats.syncRenderPatchCount++,t.renderSync()}else typeof p=="function"?s.patch(p(t.state),d):d?(t.stats.asyncRenderPatchCount++,t.qAsync=y(t.qAsync||{},p,!1),await t.renderAsync()):(t.stats.syncRenderPatchCount++,t.qSync=y(t.qSync||{},p,!1),t.renderSync())}});function r(p){let d=Date.now(),l=a(t.state);t.vode=P(t.state,e.parentElement,0,t.vode,l),e.tagName.toUpperCase()!==l[0].toUpperCase()&&(e=t.vode.node,e._vode=t),p||(t.stats.lastSyncRenderTime=Date.now()-d,t.stats.syncRenderCount++,t.isRendering=!1,t.qSync&&t.renderSync())}let c=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=y(t.state,t.qSync,!0),t.qSync=null,t.syncRenderer(c))}}),Object.defineProperty(t,"renderAsync",{enumerable:!1,configurable:!0,writable:!1,value:async()=>{if(t.isAnimating||!t.qAsync||(await h.currentViewTransition?.updateCallbackDone,t.isAnimating||!t.qAsync||document.hidden))return;t.isAnimating=!0;let p=Date.now();try{t.state=y(t.state,t.qAsync,!0),t.qAsync=null,h.currentViewTransition=t.asyncRenderer(i),await h.currentViewTransition?.updateCallbackDone}finally{t.stats.lastAsyncRenderTime=Date.now()-p,t.stats.asyncRenderCount++,t.isAnimating=!1}t.qAsync&&t.renderAsync()}}),t.state=s;let E=e;E._vode=t,t.vode=P(o,e.parentElement,Array.from(e.parentElement.children).indexOf(e),N(e,!0),a(o));for(let p of n)s.patch(p);return p=>s.patch(p)}function w(e){if(e?._vode){let a=function(t){if(!t?.node)return;let s=m(t);if(s){for(let c in s)c[0]==="o"&&c[1]==="n"&&(t.node[c]=null);t.node.catch=null}let r=C(t);if(r)for(let c of r)a(c)};var o=a;let n=e._vode;delete e._vode,Object.defineProperty(n.state,"patch",{value:void 0}),Object.defineProperty(n,"renderSync",{value:()=>{}}),Object.defineProperty(n,"renderAsync",{value:()=>{}}),a(n.vode)}}function N(e,o){if(e?.nodeType===Node.TEXT_NODE)return e.nodeValue?.trim()!==""?o?e:e.nodeValue:void 0;if(e.nodeType===Node.COMMENT_NODE)return;if(e.nodeType===Node.ELEMENT_NODE){let n=[e.tagName.toLowerCase()];if(o&&(n.node=e),e?.hasAttributes()){let t={},s=e.attributes;for(let r of s)t[r.name]=r.value;n.push(t)}if(e.hasChildNodes()){let t=[];for(let s of e.childNodes){let r=s&&N(s,o);r?n.push(r):s&&o&&t.push(s)}for(let s of t)s.remove()}return n}else return}function Y(e,o){if(!e||!Array.isArray(e))throw new Error("first argument to memo() must be an array of values to compare");if(typeof o!="function")throw new Error("second argument to memo() must be a function that returns a vode or props object");return o.__memo=e,o}function W(e){if(!e||typeof e!="object")throw new Error("createState() must be called with a state object");return e}function J(e){return e}function Q(e){return e?Array.isArray(e)?e[0]:typeof e=="string"||e.nodeType===Node.TEXT_NODE?"#text":void 0:void 0}function m(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 C(e){let o=R(e);return o>0?e.slice(o):null}function z(e){let o=R(e);return o<0?0:e.length-o}function Z(e,o){let a=R(e);if(a>0)return e[o+a]}function R(e){return m(e)?e.length>2?2:-1:Array.isArray(e)&&e.length>1?1:-1}function y(e,o,a){if(!o)return e;for(let n in o){let t=o[n];if(t&&typeof t=="object"){let s=e[n];s?Array.isArray(t)?e[n]=[...t]:t instanceof Date&&s!==t?e[n]=new Date(t):Array.isArray(s)?e[n]=y({},t,a):typeof s=="object"?y(e[n],t,a):e[n]=y({},t,a):Array.isArray(t)?e[n]=[...t]:t instanceof Date?e[n]=new Date(t):e[n]=y({},t,a)}else t===void 0&&a?delete e[n]:e[n]=t}return e}function P(e,o,a,n,t,s){try{t=D(e,t,n);let r=!t||typeof t=="number"||typeof t=="boolean";if(t===n||!n&&r)return n;let c=n?.nodeType===Node.TEXT_NODE,i=c?n:n?.node;if(r){i?.onUnmount&&e.patch(i.onUnmount(i)),i?.remove();return}let E=!r&&et(t),p=!r&&tt(t),d=!!t&&typeof t!="string"&&!!(t?.node||t?.nodeType===Node.TEXT_NODE);if(!E&&!p&&!d&&!n)throw new Error("Invalid vode: "+typeof t+" "+JSON.stringify(t));if(d&&E?t=t.wholeText:d&&p&&(t=[...t]),c&&E)return i.nodeValue!==t&&(i.nodeValue=t),n;if(E&&(!i||!c)){let l=document.createTextNode(t);return i?(i.onUnmount&&e.patch(i.onUnmount(i)),i.replaceWith(l)):o.childNodes[a]?o.insertBefore(l,o.childNodes[a]):o.appendChild(l),l}if(p&&(!i||c||n[0]!==t[0])){let l=t;1 in l&&(l[1]=D(e,l[1],void 0));let f=m(t);s=f?.xmlns||s;let S=s?document.createElementNS(s,t[0]):document.createElement(t[0]);t.node=S,v(e,S,void 0,f),f&&"catch"in f&&(t.node.catch=null,t.node.removeAttribute("catch")),i?(i.onUnmount&&e.patch(i.onUnmount(i)),i.replaceWith(S)):o.childNodes[a]?o.insertBefore(S,o.childNodes[a]):o.appendChild(S);let A=C(t);if(A)for(let T=0;T<A.length;T++){let g=A[T],x=P(e,S,T,void 0,g,s);t[f?T+2:T+1]=x}return S.onMount&&e.patch(S.onMount(S)),t}if(!c&&p&&n[0]===t[0]){t.node=i;let l=t,f=n,S=m(t),A=!!S,T=m(n);if(l[1]?.__memo){let u=l[1];l[1]=D(e,l[1],f[1]),u!==l[1]&&v(e,i,T,S)}else v(e,i,T,S);S?.catch&&T?.catch!==S.catch&&(t.node.catch=null,t.node.removeAttribute("catch"));let g=C(t),x=C(n);if(g)for(let u=0;u<g.length;u++){let b=g[u],H=x&&x[u],V=P(e,i,u,H,b,s);V&&(t[A?u+2:u+1]=V)}if(x){let u=g?g.length:0;for(let b=x.length-1;b>=u;b--)P(e,i,b,x[b],void 0,s)}return t}}catch(r){let c=m(t)?.catch;if(c){let i=typeof c=="function"?c(e,r):c;return P(e,o,a,N(t?.node||n?.node,!0),i,s)}else throw r}}function tt(e){return Array.isArray(e)&&e.length>0&&typeof e[0]=="string"}function et(e){return typeof e=="string"||e?.nodeType===Node.TEXT_NODE}function D(e,o,a){if(typeof o!="function")return o;let n=o?.__memo,t=a?.__memo;if(Array.isArray(n)&&Array.isArray(t)&&n.length===t.length){let r=!0;for(let c=0;c<n.length;c++)if(n[c]!==t[c]){r=!1;break}if(r)return a}let s=F(o,e);return typeof s=="object"&&(s.__memo=o?.__memo),s}function F(e,o){return typeof e=="function"?F(e(o),o):e}function v(e,o,a,n){if(!(!n&&!a)){if(a)for(let t in a){let s=a[t],r=n?.[t];s!==r&&(n?n[t]=M(e,o,t,s,r):M(e,o,t,s,void 0))}if(n&&a){for(let t in n)if(!(t in a)){let s=n[t];n[t]=M(e,o,t,void 0,s)}}else if(n)for(let t in n){let s=n[t];n[t]=M(e,o,t,void 0,s)}}}function M(e,o,a,n,t){if(a==="style")if(!t)o.style.cssText="";else if(typeof t=="string")n!==t&&(o.style.cssText=t);else if(n&&typeof n=="object"){for(let s in n)t[s]||(o.style[s]=null);for(let s in t){let r=n[s],c=t[s];r!==c&&(o.style[s]=c)}}else for(let s in t)o.style[s]=t[s];else if(a==="class")t?o.setAttribute("class",k(t)):o.removeAttribute("class");else if(a[0]==="o"&&a[1]==="n")if(t){let s=null;if(typeof t=="function"){let r=t;s=c=>e.patch(r(e,c))}else typeof t=="object"&&(s=()=>e.patch(t));o[a]=s}else o[a]=null;else o[a]=t,t==null||t===!1?o.removeAttribute(a):o.setAttribute(a,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(o=>e[o]).join(" "):""}var ot="a",nt="abbr",st="address",at="area",rt="article",ct="aside",it="audio",pt="b",lt="base",St="bdi",ft="bdo",dt="blockquote",ut="body",Tt="br",yt="button",gt="canvas",xt="caption",ht="cite",mt="code",Et="col",bt="colgroup",Pt="data",At="datalist",Ct="dd",Mt="del",Nt="details",Rt="dfn",Ot="dialog",Dt="div",vt="dl",Lt="dt",It="em",Vt="embed",Ft="fieldset",kt="figcaption",jt="figure",Ht="footer",Ut="form",Gt="h1",Kt="h2",Bt="h3",_t="h4",qt="h5",Xt="h6",$t="head",wt="header",Yt="hgroup",Wt="hr",Jt="html",Qt="i",zt="iframe",Zt="img",te="input",ee="ins",oe="kbd",ne="label",se="legend",ae="li",re="link",ce="main",ie="map",pe="mark",le="menu",Se="meta",fe="meter",de="nav",ue="noscript",Te="object",ye="ol",ge="optgroup",xe="option",he="output",me="p",Ee="picture",be="pre",Pe="progress",Ae="q",Ce="rp",Me="rt",Ne="ruby",Re="s",Oe="samp",De="script",ve="search",Le="section",Ie="select",Ve="slot",Fe="small",ke="source",je="span",He="strong",Ue="style",Ge="sub",Ke="summary",Be="sup",_e="table",qe="tbody",Xe="td",$e="template",we="textarea",Ye="tfoot",We="th",Je="thead",Qe="time",ze="title",Ze="tr",to="track",eo="u",oo="ul",no="var",so="video",ao="wbr",ro="animate",co="animateMotion",io="animateTransform",po="circle",lo="clipPath",So="defs",fo="desc",uo="ellipse",To="feBlend",yo="feColorMatrix",go="feComponentTransfer",xo="feComposite",ho="feConvolveMatrix",mo="feDiffuseLighting",Eo="feDisplacementMap",bo="feDistantLight",Po="feDropShadow",Ao="feFlood",Co="feFuncA",Mo="feFuncB",No="feFuncG",Ro="feFuncR",Oo="feGaussianBlur",Do="feImage",vo="feMerge",Lo="feMergeNode",Io="feMorphology",Vo="feOffset",Fo="fePointLight",ko="feSpecularLighting",jo="feSpotLight",Ho="feTile",Uo="feTurbulence",Go="filter",Ko="foreignObject",Bo="g",_o="image",qo="line",Xo="linearGradient",$o="marker",wo="mask",Yo="metadata",Wo="mpath",Jo="path",Qo="pattern",zo="polygon",Zo="polyline",tn="radialGradient",en="rect",on="set",nn="stop",sn="svg",an="switch",rn="symbol",cn="text",pn="textPath",ln="tspan",Sn="use",fn="view",dn="annotation",un="annotation-xml",Tn="maction",yn="math",gn="merror",xn="mfrac",hn="mi",mn="mmultiscripts",En="mn",bn="mo",Pn="mover",An="mpadded",Cn="mphantom",Mn="mprescripts",Nn="mroot",Rn="mrow",On="ms",Dn="mspace",vn="msqrt",Ln="mstyle",In="msub",Vn="msubsup",Fn="msup",kn="mtable",jn="mtd",Hn="mtext",Un="mtr",Gn="munder",Kn="munderover",Bn="semantics";function _n(...e){if(!e||e.length===0)return null;if(e.length===1)return e[0];let o=e[0];for(let a=1;a<e.length;a++){let n=o,t=e[a];if(!n)o=t;else if(t)if(typeof n=="string"&&typeof t=="string"){let s=n.split(" "),r=t.split(" "),c=new Set([...s,...r]);o=Array.from(c).join(" ").trim()}else if(typeof n=="string"&&Array.isArray(t)){let s=new Set([...t,...n.split(" ")]);o=Array.from(s).join(" ").trim()}else if(Array.isArray(n)&&typeof t=="string"){let s=new Set([...n,...t.split(" ")]);o=Array.from(s).join(" ").trim()}else if(Array.isArray(n)&&Array.isArray(t)){let s=new Set([...n,...t]);o=Array.from(s).join(" ").trim()}else if(typeof n=="string"&&typeof t=="object")o={[n]:!0,...t};else if(typeof n=="object"&&typeof t=="string")o={...n,[t]:!0};else if(typeof n=="object"&&typeof t=="object")o={...n,...t};else if(typeof n=="object"&&Array.isArray(t)){let s={...n};for(let r of t)s[r]=!0;o=s}else if(Array.isArray(n)&&typeof t=="object"){let s={};for(let r of n)s[r]=!0;for(let r of Object.keys(t))s[r]=t[r];o=s}else throw new Error(`cannot merge classes of ${n} (${typeof n}) and ${t} (${typeof t})`);else continue}return o}var j=document.createElement("div");function qn(...e){try{let o=j.style;for(let a of e)if(typeof a=="object"&&a!==null)for(let n in a)o[n]=a[n];else typeof a=="string"&&(o.cssText+=";"+a);return o.cssText}finally{j.style.cssText=""}}var L=class{constructor(o,a){this.state=o;this.path=a;this.keys=a.split(".")}keys;get(){let o=this.keys,a=this.state?this.state[o[0]]:void 0;for(let n=1;n<o.length&&a;n++)a=a[o[n]];return a}put(o){this.putDeep(o,this.state)}patch(o){if(Array.isArray(o)){let a=[];for(let n of o)a.push(this.createPatch(n));this.state.patch(a)}else this.state.patch(this.createPatch(o))}createPatch(o){let a={};return this.putDeep(o,a),a}putDeep(o,a){let n=this.keys;if(n.length>1){let t=0,s=a[n[t]];for((typeof s!="object"||s===null)&&(a[n[t]]=s={}),t=1;t<n.length-1;t++){let r=s;s=s[n[t]],(typeof s!="object"||s===null)&&(r[n[t]]=s={})}s[n[t]]=o}else typeof a[n[0]]=="object"&&typeof o=="object"?Object.assign(a[n[0]],o):a[n[0]]=o}},I=class{constructor(o,a,n,t){this.state=o;this.get=a;this.put=n;this.patch=t}};return q(Xn);})();
|
|
1
|
+
"use strict";var V=(()=>{var D=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var q=(e,n)=>{for(var a in n)D(e,a,{get:n[a],enumerable:!0})},X=(e,n,a,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of B(n))!_.call(e,t)&&t!==a&&D(e,t,{get:()=>n[t],enumerable:!(s=K(n,t))||s.enumerable});return e};var $=e=>X(D({},"__esModule",{value:!0}),e);var wo={};q(wo,{A:()=>st,ABBR:()=>at,ADDRESS:()=>rt,ANIMATE:()=>pn,ANIMATEMOTION:()=>ln,ANIMATETRANSFORM:()=>dn,ANNOTATION:()=>To,ANNOTATION_XML:()=>yo,AREA:()=>ct,ARTICLE:()=>it,ASIDE:()=>pt,AUDIO:()=>lt,B:()=>dt,BASE:()=>ft,BDI:()=>St,BDO:()=>ut,BLOCKQUOTE:()=>Tt,BODY:()=>yt,BR:()=>gt,BUTTON:()=>xt,CANVAS:()=>ht,CAPTION:()=>mt,CIRCLE:()=>fn,CITE:()=>Et,CLIPPATH:()=>Sn,CODE:()=>bt,COL:()=>Pt,COLGROUP:()=>At,DATA:()=>Ct,DATALIST:()=>Mt,DD:()=>Nt,DEFS:()=>un,DEL:()=>Rt,DESC:()=>Tn,DETAILS:()=>Ot,DFN:()=>Dt,DIALOG:()=>vt,DIV:()=>Lt,DL:()=>It,DT:()=>Vt,DelegateStateContext:()=>V,ELLIPSE:()=>yn,EM:()=>Ft,EMBED:()=>kt,FEBLEND:()=>gn,FECOLORMATRIX:()=>xn,FECOMPONENTTRANSFER:()=>hn,FECOMPOSITE:()=>mn,FECONVOLVEMATRIX:()=>En,FEDIFFUSELIGHTING:()=>bn,FEDISPLACEMENTMAP:()=>Pn,FEDISTANTLIGHT:()=>An,FEDROPSHADOW:()=>Cn,FEFLOOD:()=>Mn,FEFUNCA:()=>Nn,FEFUNCB:()=>Rn,FEFUNCG:()=>On,FEFUNCR:()=>Dn,FEGAUSSIANBLUR:()=>vn,FEIMAGE:()=>Ln,FEMERGE:()=>In,FEMERGENODE:()=>Vn,FEMORPHOLOGY:()=>Fn,FEOFFSET:()=>kn,FEPOINTLIGHT:()=>jn,FESPECULARLIGHTING:()=>Hn,FESPOTLIGHT:()=>Un,FETILE:()=>Gn,FETURBULENCE:()=>Kn,FIELDSET:()=>jt,FIGCAPTION:()=>Ht,FIGURE:()=>Ut,FILTER:()=>Bn,FOOTER:()=>Gt,FOREIGNOBJECT:()=>_n,FORM:()=>Kt,G:()=>qn,H1:()=>Bt,H2:()=>_t,H3:()=>qt,H4:()=>Xt,H5:()=>$t,H6:()=>wt,HEAD:()=>Yt,HEADER:()=>Wt,HGROUP:()=>Jt,HR:()=>Qt,HTML:()=>zt,I:()=>Zt,IFRAME:()=>te,IMAGE:()=>Xn,IMG:()=>ee,INPUT:()=>ne,INS:()=>oe,KBD:()=>se,KeyStateContext:()=>I,LABEL:()=>ae,LEGEND:()=>re,LI:()=>ce,LINE:()=>$n,LINEARGRADIENT:()=>wn,LINK:()=>ie,MACTION:()=>go,MAIN:()=>pe,MAP:()=>le,MARK:()=>de,MARKER:()=>Yn,MASK:()=>Wn,MATH:()=>xo,MENU:()=>fe,MERROR:()=>ho,META:()=>Se,METADATA:()=>Jn,METER:()=>ue,MFRAC:()=>mo,MI:()=>Eo,MMULTISCRIPTS:()=>bo,MN:()=>Po,MO:()=>Ao,MOVER:()=>Co,MPADDED:()=>Mo,MPATH:()=>Qn,MPHANTOM:()=>No,MPRESCRIPTS:()=>Ro,MROOT:()=>Oo,MROW:()=>Do,MS:()=>vo,MSPACE:()=>Lo,MSQRT:()=>Io,MSTYLE:()=>Vo,MSUB:()=>Fo,MSUBSUP:()=>ko,MSUP:()=>jo,MTABLE:()=>Ho,MTD:()=>Uo,MTEXT:()=>Go,MTR:()=>Ko,MUNDER:()=>Bo,MUNDEROVER:()=>_o,NAV:()=>Te,NOSCRIPT:()=>ye,OBJECT:()=>ge,OL:()=>xe,OPTGROUP:()=>he,OPTION:()=>me,OUTPUT:()=>Ee,P:()=>be,PATH:()=>zn,PATTERN:()=>Zn,PICTURE:()=>Pe,POLYGON:()=>to,POLYLINE:()=>eo,PRE:()=>Ae,PROGRESS:()=>Ce,Q:()=>Me,RADIALGRADIENT:()=>no,RECT:()=>oo,RP:()=>Ne,RT:()=>Re,RUBY:()=>Oe,S:()=>De,SAMP:()=>ve,SCRIPT:()=>Le,SEARCH:()=>Ie,SECTION:()=>Ve,SELECT:()=>Fe,SEMANTICS:()=>qo,SET:()=>so,SLOT:()=>ke,SMALL:()=>je,SOURCE:()=>He,SPAN:()=>Ue,STOP:()=>ao,STRONG:()=>Ge,STYLE:()=>Ke,SUB:()=>Be,SUMMARY:()=>_e,SUP:()=>qe,SVG:()=>ro,SWITCH:()=>co,SYMBOL:()=>io,TABLE:()=>Xe,TBODY:()=>$e,TD:()=>we,TEMPLATE:()=>Ye,TEXT:()=>po,TEXTAREA:()=>We,TEXTPATH:()=>lo,TFOOT:()=>Je,TH:()=>Qe,THEAD:()=>ze,TIME:()=>Ze,TITLE:()=>tn,TR:()=>en,TRACK:()=>nn,TSPAN:()=>fo,U:()=>on,UL:()=>sn,USE:()=>So,VAR:()=>an,VIDEO:()=>rn,VIEW:()=>uo,WBR:()=>cn,app:()=>Y,child:()=>et,childCount:()=>tt,children:()=>M,childrenStart:()=>O,createPatch:()=>z,createState:()=>Q,defuse:()=>W,globals:()=>P,hydrate:()=>R,memo:()=>J,mergeClass:()=>Xo,mergeStyle:()=>$o,props:()=>A,tag:()=>Z,vode:()=>w});var P={currentViewTransition:void 0,requestAnimationFrame:window.requestAnimationFrame?window.requestAnimationFrame.bind(window):(e=>e()),startViewTransition:document.startViewTransition?document.startViewTransition.bind(document):null};function w(e,n,...a){if(!e)throw new Error("first argument to vode() must be a tag name or a vode");return Array.isArray(e)?e:n?[e,n,...a]:[e,...a]}function Y(e,n,a,...s){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 a!="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;Object.defineProperty(n,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async(p,y)=>{if(!(!p||typeof p!="function"&&typeof p!="object"))if(t.stats.patchCount++,p?.next){let l=p;t.stats.liveEffectCount++;try{let S=await l.next();for(;S.done===!1;){t.stats.liveEffectCount++;try{o.patch(S.value,y),S=await l.next()}finally{t.stats.liveEffectCount--}}o.patch(S.value,y)}finally{t.stats.liveEffectCount--}}else if(p.then){t.stats.liveEffectCount++;try{let l=await p;o.patch(l,y)}finally{t.stats.liveEffectCount--}}else if(Array.isArray(p))if(p.length>0)for(let l of p)o.patch(l,!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 p=="function"?o.patch(p(t.state),y):y?(t.stats.asyncRenderPatchCount++,t.qAsync=E(t.qAsync||{},p,!1),await t.renderAsync()):(t.stats.syncRenderPatchCount++,t.qSync=E(t.qSync||{},p,!1),t.renderSync())}});function r(p){let y=Date.now(),l=a(t.state);t.vode=C(t.state,e.parentElement,0,0,t.vode,l),e.tagName.toUpperCase()!==l[0].toUpperCase()&&(e=t.vode.node,e._vode=t),p||(t.stats.lastSyncRenderTime=Date.now()-y,t.stats.syncRenderCount++,t.isRendering=!1,t.qSync&&t.renderSync())}let c=r.bind(null,!1),f=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(c))}}),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 p=Date.now();try{t.state=E(t.state,t.qAsync,!0),t.qAsync=null,P.currentViewTransition=t.asyncRenderer(f),await P.currentViewTransition?.updateCallbackDone}finally{t.stats.lastAsyncRenderTime=Date.now()-p,t.stats.asyncRenderCount++,t.isAnimating=!1}t.qAsync&&t.renderAsync()}}),t.state=o;let i=e;i._vode=t;let b=Array.from(e.parentElement.children).indexOf(e);t.vode=C(n,e.parentElement,b,b,R(e,!0),a(n));for(let p of s)o.patch(p);return p=>o.patch(p)}function W(e){if(e?._vode){let a=function(t){if(!t?.node)return;let o=A(t);if(o){for(let c in o)c[0]==="o"&&c[1]==="n"&&(t.node[c]=null);t.node.catch=null}let r=M(t);if(r)for(let c of r)a(c)};var n=a;let s=e._vode;delete e._vode,Object.defineProperty(s.state,"patch",{value:void 0}),Object.defineProperty(s,"renderSync",{value:()=>{}}),Object.defineProperty(s,"renderAsync",{value:()=>{}}),a(s.vode)}}function R(e,n){if(e?.nodeType===Node.TEXT_NODE)return e.nodeValue?.trim()!==""?n?e:e.nodeValue:void 0;if(e.nodeType===Node.COMMENT_NODE)return;if(e.nodeType===Node.ELEMENT_NODE){let s=[e.tagName.toLowerCase()];if(n&&(s.node=e),e?.hasAttributes()){let t={},o=e.attributes;for(let r of o)t[r.name]=r.value;s.push(t)}if(e.hasChildNodes()){let t=[];for(let o of e.childNodes){let r=o&&R(o,n);r?s.push(r):o&&n&&t.push(o)}for(let o of t)o.remove()}return s}else return}function J(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 Q(e){if(!e||typeof e!="object")throw new Error("createState() must be called with a state object");return e}function z(e){return e}function Z(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 tt(e){let n=O(e);return n<0?0:e.length-n}function et(e,n){let a=O(e);if(a>0)return e[n+a]}function O(e){return A(e)?e.length>2?2:-1:Array.isArray(e)&&e.length>1?1:-1}function E(e,n,a){if(!n)return e;for(let s in n){let t=n[s];if(t&&typeof t=="object"){let o=e[s];o?Array.isArray(t)?e[s]=[...t]:t instanceof Date&&o!==t?e[s]=new Date(t):Array.isArray(o)?e[s]=E({},t,a):typeof o=="object"?E(e[s],t,a):e[s]=E({},t,a):Array.isArray(t)?e[s]=[...t]:t instanceof Date?e[s]=new Date(t):e[s]=E({},t,a)}else t===void 0&&a?delete e[s]:e[s]=t}return e}function C(e,n,a,s,t,o,r){try{o=v(e,o,t);let c=!o||typeof o=="number"||typeof o=="boolean";if(o===t||!t&&c)return t;let f=t?.nodeType===Node.TEXT_NODE,i=f?t:t?.node;if(c){i?.onUnmount&&e.patch(i.onUnmount(i)),i?.remove();return}let b=!c&&ot(o),p=!c&&nt(o),y=!!o&&typeof o!="string"&&!!(o?.node||o?.nodeType===Node.TEXT_NODE);if(!b&&!p&&!y&&!t)throw new Error("Invalid vode: "+typeof o+" "+JSON.stringify(o));if(y&&b?o=o.wholeText:y&&p&&(o=[...o]),f&&b)return i.nodeValue!==o&&(i.nodeValue=o),t;if(b&&(!i||!f)){let l=document.createTextNode(o);if(i)i.onUnmount&&e.patch(i.onUnmount(i)),i.replaceWith(l);else{let S=!1;for(let d=0;d<n.childNodes.length;d++){let g=n.childNodes[s+d];if(g){g.before(l,g),S=!0;break}}S||n.appendChild(l)}return l}if(p&&(!i||f||t[0]!==o[0])){let l=o;1 in l&&(l[1]=v(e,l[1],void 0));let S=A(o);S?.xmlns!==void 0&&(r=S.xmlns);let d=r?document.createElementNS(r,o[0]):document.createElement(o[0]);if(o.node=d,L(e,d,void 0,S,r),S&&"catch"in S&&(o.node.catch=null,o.node.removeAttribute("catch")),i)i.onUnmount&&e.patch(i.onUnmount(i)),i.replaceWith(d);else{let x=!1;for(let T=0;T<n.childNodes.length;T++){let u=n.childNodes[s+T];if(u){u.before(d,u),x=!0;break}}x||n.appendChild(d)}let g=M(o);if(g){let x=S?2:1,T=0;for(let u=0;u<g.length;u++){let h=g[u],m=C(e,d,u,T,void 0,h,r);o[u+x]=m,m&&T++}}return d.onMount&&e.patch(d.onMount(d)),o}if(!f&&p&&t[0]===o[0]){o.node=i;let l=o,S=t,d=A(o),g=A(t);if(d?.xmlns!==void 0&&(r=d.xmlns),l[1]?.__memo){let u=l[1];l[1]=v(e,l[1],S[1]),u!==l[1]&&L(e,i,g,d,r)}else L(e,i,g,d,r);d?.catch&&g?.catch!==d.catch&&(o.node.catch=null,o.node.removeAttribute("catch"));let x=M(o),T=M(t);if(x){let u=d?2:1,h=0;for(let m=0;m<x.length;m++){let U=x[m],G=T&&T[m],F=C(e,i,m,h,G,U,r);o[m+u]=F,F&&h++}}if(T){let u=x?x.length:0;for(let h=T.length-1;h>=u;h--)C(e,i,h,h,T[h],void 0,r)}return o}}catch(c){let f=A(o)?.catch;if(f){let i=typeof f=="function"?f(e,c):f;return C(e,n,a,s,R(o?.node||t?.node,!0),i,r)}else throw c}}function nt(e){return Array.isArray(e)&&e.length>0&&typeof e[0]=="string"}function ot(e){return typeof e=="string"||e?.nodeType===Node.TEXT_NODE}function v(e,n,a){if(typeof n!="function")return n;let s=n?.__memo,t=a?.__memo;if(Array.isArray(s)&&Array.isArray(t)&&s.length===t.length){let r=!0;for(let c=0;c<s.length;c++)if(s[c]!==t[c]){r=!1;break}if(r)return a}let o=k(n,e);return typeof o=="object"&&(o.__memo=n?.__memo),o}function k(e,n){return typeof e=="function"?k(e(n),n):e}function L(e,n,a,s,t){if(!s&&!a)return;let o=t!==void 0;if(a)for(let r in a){let c=a[r],f=s?.[r];c!==f&&(s?s[r]=N(e,n,r,c,f,o):N(e,n,r,c,void 0,o))}if(s&&a){for(let r in s)if(!(r in a)){let c=s[r];s[r]=N(e,n,r,void 0,c,o)}}else if(s)for(let r in s){let c=s[r];s[r]=N(e,n,r,void 0,c,o)}}function N(e,n,a,s,t,o){if(a==="style")if(!t)n.style.cssText="";else if(typeof t=="string")s!==t&&(n.style.cssText=t);else if(s&&typeof s=="object"){for(let r in s)t[r]||(n.style[r]=null);for(let r in t){let c=s[r],f=t[r];c!==f&&(n.style[r]=f)}}else for(let r in t)n.style[r]=t[r];else if(a==="class")t?n.setAttribute("class",j(t)):n.removeAttribute("class");else if(a[0]==="o"&&a[1]==="n")if(t){let r=null;if(typeof t=="function"){let c=t;r=f=>e.patch(c(e,f))}else typeof t=="object"&&(r=()=>e.patch(t));n[a]=r}else n[a]=null;else o||(n[a]=t),t==null||t===!1?n.removeAttribute(a):n.setAttribute(a,t);return t}function j(e){return typeof e=="string"?e:Array.isArray(e)?e.map(j).join(" "):typeof e=="object"?Object.keys(e).filter(n=>e[n]).join(" "):""}var st="a",at="abbr",rt="address",ct="area",it="article",pt="aside",lt="audio",dt="b",ft="base",St="bdi",ut="bdo",Tt="blockquote",yt="body",gt="br",xt="button",ht="canvas",mt="caption",Et="cite",bt="code",Pt="col",At="colgroup",Ct="data",Mt="datalist",Nt="dd",Rt="del",Ot="details",Dt="dfn",vt="dialog",Lt="div",It="dl",Vt="dt",Ft="em",kt="embed",jt="fieldset",Ht="figcaption",Ut="figure",Gt="footer",Kt="form",Bt="h1",_t="h2",qt="h3",Xt="h4",$t="h5",wt="h6",Yt="head",Wt="header",Jt="hgroup",Qt="hr",zt="html",Zt="i",te="iframe",ee="img",ne="input",oe="ins",se="kbd",ae="label",re="legend",ce="li",ie="link",pe="main",le="map",de="mark",fe="menu",Se="meta",ue="meter",Te="nav",ye="noscript",ge="object",xe="ol",he="optgroup",me="option",Ee="output",be="p",Pe="picture",Ae="pre",Ce="progress",Me="q",Ne="rp",Re="rt",Oe="ruby",De="s",ve="samp",Le="script",Ie="search",Ve="section",Fe="select",ke="slot",je="small",He="source",Ue="span",Ge="strong",Ke="style",Be="sub",_e="summary",qe="sup",Xe="table",$e="tbody",we="td",Ye="template",We="textarea",Je="tfoot",Qe="th",ze="thead",Ze="time",tn="title",en="tr",nn="track",on="u",sn="ul",an="var",rn="video",cn="wbr",pn="animate",ln="animateMotion",dn="animateTransform",fn="circle",Sn="clipPath",un="defs",Tn="desc",yn="ellipse",gn="feBlend",xn="feColorMatrix",hn="feComponentTransfer",mn="feComposite",En="feConvolveMatrix",bn="feDiffuseLighting",Pn="feDisplacementMap",An="feDistantLight",Cn="feDropShadow",Mn="feFlood",Nn="feFuncA",Rn="feFuncB",On="feFuncG",Dn="feFuncR",vn="feGaussianBlur",Ln="feImage",In="feMerge",Vn="feMergeNode",Fn="feMorphology",kn="feOffset",jn="fePointLight",Hn="feSpecularLighting",Un="feSpotLight",Gn="feTile",Kn="feTurbulence",Bn="filter",_n="foreignObject",qn="g",Xn="image",$n="line",wn="linearGradient",Yn="marker",Wn="mask",Jn="metadata",Qn="mpath",zn="path",Zn="pattern",to="polygon",eo="polyline",no="radialGradient",oo="rect",so="set",ao="stop",ro="svg",co="switch",io="symbol",po="text",lo="textPath",fo="tspan",So="use",uo="view",To="annotation",yo="annotation-xml",go="maction",xo="math",ho="merror",mo="mfrac",Eo="mi",bo="mmultiscripts",Po="mn",Ao="mo",Co="mover",Mo="mpadded",No="mphantom",Ro="mprescripts",Oo="mroot",Do="mrow",vo="ms",Lo="mspace",Io="msqrt",Vo="mstyle",Fo="msub",ko="msubsup",jo="msup",Ho="mtable",Uo="mtd",Go="mtext",Ko="mtr",Bo="munder",_o="munderover",qo="semantics";function Xo(...e){if(!e||e.length===0)return null;if(e.length===1)return e[0];let n=e[0];for(let a=1;a<e.length;a++){let s=n,t=e[a];if(!s)n=t;else if(t)if(typeof s=="string"&&typeof t=="string"){let o=s.split(" "),r=t.split(" "),c=new Set([...o,...r]);n=Array.from(c).join(" ").trim()}else if(typeof s=="string"&&Array.isArray(t)){let o=new Set([...t,...s.split(" ")]);n=Array.from(o).join(" ").trim()}else if(Array.isArray(s)&&typeof t=="string"){let o=new Set([...s,...t.split(" ")]);n=Array.from(o).join(" ").trim()}else if(Array.isArray(s)&&Array.isArray(t)){let o=new Set([...s,...t]);n=Array.from(o).join(" ").trim()}else if(typeof s=="string"&&typeof t=="object")n={[s]:!0,...t};else if(typeof s=="object"&&typeof t=="string")n={...s,[t]:!0};else if(typeof s=="object"&&typeof t=="object")n={...s,...t};else if(typeof s=="object"&&Array.isArray(t)){let o={...s};for(let r of t)o[r]=!0;n=o}else if(Array.isArray(s)&&typeof t=="object"){let o={};for(let r of s)o[r]=!0;for(let r of Object.keys(t))o[r]=t[r];n=o}else throw new Error(`cannot merge classes of ${s} (${typeof s}) and ${t} (${typeof t})`);else continue}return n}var H=document.createElement("div");function $o(...e){try{let n=H.style;for(let a of e)if(typeof a=="object"&&a!==null)for(let s in a)n[s]=a[s];else typeof a=="string"&&(n.cssText+=";"+a);return n.cssText}finally{H.style.cssText=""}}var I=class{constructor(n,a){this.state=n;this.path=a;this.keys=a.split(".")}keys;get(){let n=this.keys,a=this.state?this.state[n[0]]:void 0;for(let s=1;s<n.length&&a;s++)a=a[n[s]];return a}put(n){this.putDeep(n,this.state)}patch(n){if(Array.isArray(n)){let a=[];for(let s of n)a.push(this.createPatch(s));this.state.patch(a)}else this.state.patch(this.createPatch(n))}createPatch(n){let a={};return this.putDeep(n,a),a}putDeep(n,a){let s=this.keys;if(s.length>1){let t=0,o=a[s[t]];for((typeof o!="object"||o===null)&&(a[s[t]]=o={}),t=1;t<s.length-1;t++){let r=o;o=o[s[t]],(typeof o!="object"||o===null)&&(r[s[t]]=o={})}o[s[t]]=n}else typeof a[s[0]]=="object"&&typeof n=="object"?Object.assign(a[s[0]],n):a[s[0]]=n}},V=class{constructor(n,a,s,t){this.state=n;this.get=a;this.put=s;this.patch=t}};return $(wo);})();
|
package/dist/vode.min.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var E={currentViewTransition:void 0,requestAnimationFrame:window.requestAnimationFrame?window.requestAnimationFrame.bind(window):(e=>e()),startViewTransition:document.startViewTransition?document.startViewTransition.bind(document):null};function G(e,n,...a){if(!e)throw new Error("first argument to vode() must be a tag name or a vode");return Array.isArray(e)?e:n?[e,n,...a]:[e,...a]}function K(e,n,a,...o){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 a!="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.qSync=null,t.qAsync=null,t.stats={lastSyncRenderTime:0,lastAsyncRenderTime:0,syncRenderCount:0,asyncRenderCount:0,liveEffectCount:0,patchCount:0,syncRenderPatchCount:0,asyncRenderPatchCount:0};let s=n;Object.defineProperty(n,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async(p,d)=>{if(!(!p||typeof p!="function"&&typeof p!="object"))if(t.stats.patchCount++,p?.next){let l=p;t.stats.liveEffectCount++;try{let f=await l.next();for(;f.done===!1;){t.stats.liveEffectCount++;try{s.patch(f.value,d),f=await l.next()}finally{t.stats.liveEffectCount--}}s.patch(f.value,d)}finally{t.stats.liveEffectCount--}}else if(p.then){t.stats.liveEffectCount++;try{let l=await p;s.patch(l,d)}finally{t.stats.liveEffectCount--}}else if(Array.isArray(p))if(p.length>0)for(let l of p)s.patch(l,!document.hidden&&!!t.asyncRenderer);else{t.qSync=y(t.qSync||{},t.qAsync,!1),t.qAsync=null;try{E.currentViewTransition?.skipTransition()}catch{}t.stats.syncRenderPatchCount++,t.renderSync()}else typeof p=="function"?s.patch(p(t.state),d):d?(t.stats.asyncRenderPatchCount++,t.qAsync=y(t.qAsync||{},p,!1),await t.renderAsync()):(t.stats.syncRenderPatchCount++,t.qSync=y(t.qSync||{},p,!1),t.renderSync())}});function r(p){let d=Date.now(),l=a(t.state);t.vode=P(t.state,e.parentElement,0,t.vode,l),e.tagName.toUpperCase()!==l[0].toUpperCase()&&(e=t.vode.node,e._vode=t),p||(t.stats.lastSyncRenderTime=Date.now()-d,t.stats.syncRenderCount++,t.isRendering=!1,t.qSync&&t.renderSync())}let c=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=y(t.state,t.qSync,!0),t.qSync=null,t.syncRenderer(c))}}),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 p=Date.now();try{t.state=y(t.state,t.qAsync,!0),t.qAsync=null,E.currentViewTransition=t.asyncRenderer(i),await E.currentViewTransition?.updateCallbackDone}finally{t.stats.lastAsyncRenderTime=Date.now()-p,t.stats.asyncRenderCount++,t.isAnimating=!1}t.qAsync&&t.renderAsync()}}),t.state=s;let h=e;h._vode=t,t.vode=P(n,e.parentElement,Array.from(e.parentElement.children).indexOf(e),O(e,!0),a(n));for(let p of o)s.patch(p);return p=>s.patch(p)}function B(e){if(e?._vode){let a=function(t){if(!t?.node)return;let s=b(t);if(s){for(let c in s)c[0]==="o"&&c[1]==="n"&&(t.node[c]=null);t.node.catch=null}let r=M(t);if(r)for(let c of r)a(c)};var n=a;let o=e._vode;delete e._vode,Object.defineProperty(o.state,"patch",{value:void 0}),Object.defineProperty(o,"renderSync",{value:()=>{}}),Object.defineProperty(o,"renderAsync",{value:()=>{}}),a(o.vode)}}function O(e,n){if(e?.nodeType===Node.TEXT_NODE)return e.nodeValue?.trim()!==""?n?e:e.nodeValue:void 0;if(e.nodeType===Node.COMMENT_NODE)return;if(e.nodeType===Node.ELEMENT_NODE){let o=[e.tagName.toLowerCase()];if(n&&(o.node=e),e?.hasAttributes()){let t={},s=e.attributes;for(let r of s)t[r.name]=r.value;o.push(t)}if(e.hasChildNodes()){let t=[];for(let s of e.childNodes){let r=s&&O(s,n);r?o.push(r):s&&n&&t.push(s)}for(let s of t)s.remove()}return o}else return}function _(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 q(e){if(!e||typeof e!="object")throw new Error("createState() must be called with a state object");return e}function X(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 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 M(e){let n=D(e);return n>0?e.slice(n):null}function w(e){let n=D(e);return n<0?0:e.length-n}function Y(e,n){let a=D(e);if(a>0)return e[n+a]}function D(e){return b(e)?e.length>2?2:-1:Array.isArray(e)&&e.length>1?1:-1}function y(e,n,a){if(!n)return e;for(let o in n){let t=n[o];if(t&&typeof t=="object"){let s=e[o];s?Array.isArray(t)?e[o]=[...t]:t instanceof Date&&s!==t?e[o]=new Date(t):Array.isArray(s)?e[o]=y({},t,a):typeof s=="object"?y(e[o],t,a):e[o]=y({},t,a):Array.isArray(t)?e[o]=[...t]:t instanceof Date?e[o]=new Date(t):e[o]=y({},t,a)}else t===void 0&&a?delete e[o]:e[o]=t}return e}function P(e,n,a,o,t,s){try{t=N(e,t,o);let r=!t||typeof t=="number"||typeof t=="boolean";if(t===o||!o&&r)return o;let c=o?.nodeType===Node.TEXT_NODE,i=c?o:o?.node;if(r){i?.onUnmount&&e.patch(i.onUnmount(i)),i?.remove();return}let h=!r&&U(t),p=!r&&H(t),d=!!t&&typeof t!="string"&&!!(t?.node||t?.nodeType===Node.TEXT_NODE);if(!h&&!p&&!d&&!o)throw new Error("Invalid vode: "+typeof t+" "+JSON.stringify(t));if(d&&h?t=t.wholeText:d&&p&&(t=[...t]),c&&h)return i.nodeValue!==t&&(i.nodeValue=t),o;if(h&&(!i||!c)){let l=document.createTextNode(t);return i?(i.onUnmount&&e.patch(i.onUnmount(i)),i.replaceWith(l)):n.childNodes[a]?n.insertBefore(l,n.childNodes[a]):n.appendChild(l),l}if(p&&(!i||c||o[0]!==t[0])){let l=t;1 in l&&(l[1]=N(e,l[1],void 0));let f=b(t);s=f?.xmlns||s;let S=s?document.createElementNS(s,t[0]):document.createElement(t[0]);t.node=S,R(e,S,void 0,f),f&&"catch"in f&&(t.node.catch=null,t.node.removeAttribute("catch")),i?(i.onUnmount&&e.patch(i.onUnmount(i)),i.replaceWith(S)):n.childNodes[a]?n.insertBefore(S,n.childNodes[a]):n.appendChild(S);let A=M(t);if(A)for(let T=0;T<A.length;T++){let g=A[T],x=P(e,S,T,void 0,g,s);t[f?T+2:T+1]=x}return S.onMount&&e.patch(S.onMount(S)),t}if(!c&&p&&o[0]===t[0]){t.node=i;let l=t,f=o,S=b(t),A=!!S,T=b(o);if(l[1]?.__memo){let u=l[1];l[1]=N(e,l[1],f[1]),u!==l[1]&&R(e,i,T,S)}else R(e,i,T,S);S?.catch&&T?.catch!==S.catch&&(t.node.catch=null,t.node.removeAttribute("catch"));let g=M(t),x=M(o);if(g)for(let u=0;u<g.length;u++){let m=g[u],j=x&&x[u],v=P(e,i,u,j,m,s);v&&(t[A?u+2:u+1]=v)}if(x){let u=g?g.length:0;for(let m=x.length-1;m>=u;m--)P(e,i,m,x[m],void 0,s)}return t}}catch(r){let c=b(t)?.catch;if(c){let i=typeof c=="function"?c(e,r):c;return P(e,n,a,O(t?.node||o?.node,!0),i,s)}else throw r}}function H(e){return Array.isArray(e)&&e.length>0&&typeof e[0]=="string"}function U(e){return typeof e=="string"||e?.nodeType===Node.TEXT_NODE}function N(e,n,a){if(typeof n!="function")return n;let o=n?.__memo,t=a?.__memo;if(Array.isArray(o)&&Array.isArray(t)&&o.length===t.length){let r=!0;for(let c=0;c<o.length;c++)if(o[c]!==t[c]){r=!1;break}if(r)return a}let s=L(n,e);return typeof s=="object"&&(s.__memo=n?.__memo),s}function L(e,n){return typeof e=="function"?L(e(n),n):e}function R(e,n,a,o){if(!(!o&&!a)){if(a)for(let t in a){let s=a[t],r=o?.[t];s!==r&&(o?o[t]=C(e,n,t,s,r):C(e,n,t,s,void 0))}if(o&&a){for(let t in o)if(!(t in a)){let s=o[t];o[t]=C(e,n,t,void 0,s)}}else if(o)for(let t in o){let s=o[t];o[t]=C(e,n,t,void 0,s)}}}function C(e,n,a,o,t){if(a==="style")if(!t)n.style.cssText="";else if(typeof t=="string")o!==t&&(n.style.cssText=t);else if(o&&typeof o=="object"){for(let s in o)t[s]||(n.style[s]=null);for(let s in t){let r=o[s],c=t[s];r!==c&&(n.style[s]=c)}}else for(let s in t)n.style[s]=t[s];else if(a==="class")t?n.setAttribute("class",I(t)):n.removeAttribute("class");else if(a[0]==="o"&&a[1]==="n")if(t){let s=null;if(typeof t=="function"){let r=t;s=c=>e.patch(r(e,c))}else typeof t=="object"&&(s=()=>e.patch(t));n[a]=s}else n[a]=null;else n[a]=t,t==null||t===!1?n.removeAttribute(a):n.setAttribute(a,t);return t}function I(e){return typeof e=="string"?e:Array.isArray(e)?e.map(I).join(" "):typeof e=="object"?Object.keys(e).filter(n=>e[n]).join(" "):""}var J="a",Q="abbr",z="address",Z="area",tt="article",et="aside",ot="audio",nt="b",st="base",at="bdi",rt="bdo",ct="blockquote",it="body",pt="br",lt="button",St="canvas",ft="caption",dt="cite",ut="code",Tt="col",yt="colgroup",gt="data",xt="datalist",ht="dd",mt="del",Et="details",bt="dfn",Pt="dialog",At="div",Ct="dl",Mt="dt",Nt="em",Rt="embed",Ot="fieldset",Dt="figcaption",vt="figure",Lt="footer",It="form",Vt="h1",Ft="h2",kt="h3",jt="h4",Ht="h5",Ut="h6",Gt="head",Kt="header",Bt="hgroup",_t="hr",qt="html",Xt="i",$t="iframe",wt="img",Yt="input",Wt="ins",Jt="kbd",Qt="label",zt="legend",Zt="li",te="link",ee="main",oe="map",ne="mark",se="menu",ae="meta",re="meter",ce="nav",ie="noscript",pe="object",le="ol",Se="optgroup",fe="option",de="output",ue="p",Te="picture",ye="pre",ge="progress",xe="q",he="rp",me="rt",Ee="ruby",be="s",Pe="samp",Ae="script",Ce="search",Me="section",Ne="select",Re="slot",Oe="small",De="source",ve="span",Le="strong",Ie="style",Ve="sub",Fe="summary",ke="sup",je="table",He="tbody",Ue="td",Ge="template",Ke="textarea",Be="tfoot",_e="th",qe="thead",Xe="time",$e="title",we="tr",Ye="track",We="u",Je="ul",Qe="var",ze="video",Ze="wbr",to="animate",eo="animateMotion",oo="animateTransform",no="circle",so="clipPath",ao="defs",ro="desc",co="ellipse",io="feBlend",po="feColorMatrix",lo="feComponentTransfer",So="feComposite",fo="feConvolveMatrix",uo="feDiffuseLighting",To="feDisplacementMap",yo="feDistantLight",go="feDropShadow",xo="feFlood",ho="feFuncA",mo="feFuncB",Eo="feFuncG",bo="feFuncR",Po="feGaussianBlur",Ao="feImage",Co="feMerge",Mo="feMergeNode",No="feMorphology",Ro="feOffset",Oo="fePointLight",Do="feSpecularLighting",vo="feSpotLight",Lo="feTile",Io="feTurbulence",Vo="filter",Fo="foreignObject",ko="g",jo="image",Ho="line",Uo="linearGradient",Go="marker",Ko="mask",Bo="metadata",_o="mpath",qo="path",Xo="pattern",$o="polygon",wo="polyline",Yo="radialGradient",Wo="rect",Jo="set",Qo="stop",zo="svg",Zo="switch",tn="symbol",en="text",on="textPath",nn="tspan",sn="use",an="view",rn="annotation",cn="annotation-xml",pn="maction",ln="math",Sn="merror",fn="mfrac",dn="mi",un="mmultiscripts",Tn="mn",yn="mo",gn="mover",xn="mpadded",hn="mphantom",mn="mprescripts",En="mroot",bn="mrow",Pn="ms",An="mspace",Cn="msqrt",Mn="mstyle",Nn="msub",Rn="msubsup",On="msup",Dn="mtable",vn="mtd",Ln="mtext",In="mtr",Vn="munder",Fn="munderover",kn="semantics";function Hn(...e){if(!e||e.length===0)return null;if(e.length===1)return e[0];let n=e[0];for(let a=1;a<e.length;a++){let o=n,t=e[a];if(!o)n=t;else if(t)if(typeof o=="string"&&typeof t=="string"){let s=o.split(" "),r=t.split(" "),c=new Set([...s,...r]);n=Array.from(c).join(" ").trim()}else if(typeof o=="string"&&Array.isArray(t)){let s=new Set([...t,...o.split(" ")]);n=Array.from(s).join(" ").trim()}else if(Array.isArray(o)&&typeof t=="string"){let s=new Set([...o,...t.split(" ")]);n=Array.from(s).join(" ").trim()}else if(Array.isArray(o)&&Array.isArray(t)){let s=new Set([...o,...t]);n=Array.from(s).join(" ").trim()}else if(typeof o=="string"&&typeof t=="object")n={[o]:!0,...t};else if(typeof o=="object"&&typeof t=="string")n={...o,[t]:!0};else if(typeof o=="object"&&typeof t=="object")n={...o,...t};else if(typeof o=="object"&&Array.isArray(t)){let s={...o};for(let r of t)s[r]=!0;n=s}else if(Array.isArray(o)&&typeof t=="object"){let s={};for(let r of o)s[r]=!0;for(let r of Object.keys(t))s[r]=t[r];n=s}else throw new Error(`cannot merge classes of ${o} (${typeof o}) and ${t} (${typeof t})`);else continue}return n}var V=document.createElement("div");function Gn(...e){try{let n=V.style;for(let a of e)if(typeof a=="object"&&a!==null)for(let o in a)n[o]=a[o];else typeof a=="string"&&(n.cssText+=";"+a);return n.cssText}finally{V.style.cssText=""}}var F=class{constructor(n,a){this.state=n;this.path=a;this.keys=a.split(".")}keys;get(){let n=this.keys,a=this.state?this.state[n[0]]:void 0;for(let o=1;o<n.length&&a;o++)a=a[n[o]];return a}put(n){this.putDeep(n,this.state)}patch(n){if(Array.isArray(n)){let a=[];for(let o of n)a.push(this.createPatch(o));this.state.patch(a)}else this.state.patch(this.createPatch(n))}createPatch(n){let a={};return this.putDeep(n,a),a}putDeep(n,a){let o=this.keys;if(o.length>1){let t=0,s=a[o[t]];for((typeof s!="object"||s===null)&&(a[o[t]]=s={}),t=1;t<o.length-1;t++){let r=s;s=s[o[t]],(typeof s!="object"||s===null)&&(r[o[t]]=s={})}s[o[t]]=n}else typeof a[o[0]]=="object"&&typeof n=="object"?Object.assign(a[o[0]],n):a[o[0]]=n}},k=class{constructor(n,a,o,t){this.state=n;this.get=a;this.put=o;this.patch=t}};export{J as A,Q as ABBR,z as ADDRESS,to as ANIMATE,eo as ANIMATEMOTION,oo as ANIMATETRANSFORM,rn as ANNOTATION,cn as ANNOTATION_XML,Z as AREA,tt as ARTICLE,et as ASIDE,ot as AUDIO,nt as B,st as BASE,at as BDI,rt as BDO,ct as BLOCKQUOTE,it as BODY,pt as BR,lt as BUTTON,St as CANVAS,ft as CAPTION,no as CIRCLE,dt as CITE,so as CLIPPATH,ut as CODE,Tt as COL,yt as COLGROUP,gt as DATA,xt as DATALIST,ht as DD,ao as DEFS,mt as DEL,ro as DESC,Et as DETAILS,bt as DFN,Pt as DIALOG,At as DIV,Ct as DL,Mt as DT,k as DelegateStateContext,co as ELLIPSE,Nt as EM,Rt as EMBED,io as FEBLEND,po as FECOLORMATRIX,lo as FECOMPONENTTRANSFER,So as FECOMPOSITE,fo as FECONVOLVEMATRIX,uo as FEDIFFUSELIGHTING,To as FEDISPLACEMENTMAP,yo as FEDISTANTLIGHT,go as FEDROPSHADOW,xo as FEFLOOD,ho as FEFUNCA,mo as FEFUNCB,Eo as FEFUNCG,bo as FEFUNCR,Po as FEGAUSSIANBLUR,Ao as FEIMAGE,Co as FEMERGE,Mo as FEMERGENODE,No as FEMORPHOLOGY,Ro as FEOFFSET,Oo as FEPOINTLIGHT,Do as FESPECULARLIGHTING,vo as FESPOTLIGHT,Lo as FETILE,Io as FETURBULENCE,Ot as FIELDSET,Dt as FIGCAPTION,vt as FIGURE,Vo as FILTER,Lt as FOOTER,Fo as FOREIGNOBJECT,It as FORM,ko as G,Vt as H1,Ft as H2,kt as H3,jt as H4,Ht as H5,Ut as H6,Gt as HEAD,Kt as HEADER,Bt as HGROUP,_t as HR,qt as HTML,Xt as I,$t as IFRAME,jo as IMAGE,wt as IMG,Yt as INPUT,Wt as INS,Jt as KBD,F as KeyStateContext,Qt as LABEL,zt as LEGEND,Zt as LI,Ho as LINE,Uo as LINEARGRADIENT,te as LINK,pn as MACTION,ee as MAIN,oe as MAP,ne as MARK,Go as MARKER,Ko as MASK,ln as MATH,se as MENU,Sn as MERROR,ae as META,Bo as METADATA,re as METER,fn as MFRAC,dn as MI,un as MMULTISCRIPTS,Tn as MN,yn as MO,gn as MOVER,xn as MPADDED,_o as MPATH,hn as MPHANTOM,mn as MPRESCRIPTS,En as MROOT,bn as MROW,Pn as MS,An as MSPACE,Cn as MSQRT,Mn as MSTYLE,Nn as MSUB,Rn as MSUBSUP,On as MSUP,Dn as MTABLE,vn as MTD,Ln as MTEXT,In as MTR,Vn as MUNDER,Fn as MUNDEROVER,ce as NAV,ie as NOSCRIPT,pe as OBJECT,le as OL,Se as OPTGROUP,fe as OPTION,de as OUTPUT,ue as P,qo as PATH,Xo as PATTERN,Te as PICTURE,$o as POLYGON,wo as POLYLINE,ye as PRE,ge as PROGRESS,xe as Q,Yo as RADIALGRADIENT,Wo as RECT,he as RP,me as RT,Ee as RUBY,be as S,Pe as SAMP,Ae as SCRIPT,Ce as SEARCH,Me as SECTION,Ne as SELECT,kn as SEMANTICS,Jo as SET,Re as SLOT,Oe as SMALL,De as SOURCE,ve as SPAN,Qo as STOP,Le as STRONG,Ie as STYLE,Ve as SUB,Fe as SUMMARY,ke as SUP,zo as SVG,Zo as SWITCH,tn as SYMBOL,je as TABLE,He as TBODY,Ue as TD,Ge as TEMPLATE,en as TEXT,Ke as TEXTAREA,on as TEXTPATH,Be as TFOOT,_e as TH,qe as THEAD,Xe as TIME,$e as TITLE,we as TR,Ye as TRACK,nn as TSPAN,We as U,Je as UL,sn as USE,Qe as VAR,ze as VIDEO,an as VIEW,Ze as WBR,K as app,Y as child,w as childCount,M as children,D as childrenStart,X as createPatch,q as createState,B as defuse,E as globals,O as hydrate,_ as memo,Hn as mergeClass,Gn as mergeStyle,b as props,$ as tag,G as vode};
|
|
1
|
+
var P={currentViewTransition:void 0,requestAnimationFrame:window.requestAnimationFrame?window.requestAnimationFrame.bind(window):(e=>e()),startViewTransition:document.startViewTransition?document.startViewTransition.bind(document):null};function B(e,o,...a){if(!e)throw new Error("first argument to vode() must be a tag name or a vode");return Array.isArray(e)?e:o?[e,o,...a]:[e,...a]}function _(e,o,a,...s){if(!e?.parentElement)throw new Error("first argument to app() must be a valid HTMLElement inside the <html></html> document");if(!o||typeof o!="object")throw new Error("second argument to app() must be a state object");if(typeof a!="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 n=o;Object.defineProperty(o,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async(p,y)=>{if(!(!p||typeof p!="function"&&typeof p!="object"))if(t.stats.patchCount++,p?.next){let l=p;t.stats.liveEffectCount++;try{let S=await l.next();for(;S.done===!1;){t.stats.liveEffectCount++;try{n.patch(S.value,y),S=await l.next()}finally{t.stats.liveEffectCount--}}n.patch(S.value,y)}finally{t.stats.liveEffectCount--}}else if(p.then){t.stats.liveEffectCount++;try{let l=await p;n.patch(l,y)}finally{t.stats.liveEffectCount--}}else if(Array.isArray(p))if(p.length>0)for(let l of p)n.patch(l,!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 p=="function"?n.patch(p(t.state),y):y?(t.stats.asyncRenderPatchCount++,t.qAsync=E(t.qAsync||{},p,!1),await t.renderAsync()):(t.stats.syncRenderPatchCount++,t.qSync=E(t.qSync||{},p,!1),t.renderSync())}});function r(p){let y=Date.now(),l=a(t.state);t.vode=C(t.state,e.parentElement,0,0,t.vode,l),e.tagName.toUpperCase()!==l[0].toUpperCase()&&(e=t.vode.node,e._vode=t),p||(t.stats.lastSyncRenderTime=Date.now()-y,t.stats.syncRenderCount++,t.isRendering=!1,t.qSync&&t.renderSync())}let c=r.bind(null,!1),f=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(c))}}),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 p=Date.now();try{t.state=E(t.state,t.qAsync,!0),t.qAsync=null,P.currentViewTransition=t.asyncRenderer(f),await P.currentViewTransition?.updateCallbackDone}finally{t.stats.lastAsyncRenderTime=Date.now()-p,t.stats.asyncRenderCount++,t.isAnimating=!1}t.qAsync&&t.renderAsync()}}),t.state=n;let i=e;i._vode=t;let b=Array.from(e.parentElement.children).indexOf(e);t.vode=C(o,e.parentElement,b,b,D(e,!0),a(o));for(let p of s)n.patch(p);return p=>n.patch(p)}function q(e){if(e?._vode){let a=function(t){if(!t?.node)return;let n=A(t);if(n){for(let c in n)c[0]==="o"&&c[1]==="n"&&(t.node[c]=null);t.node.catch=null}let r=N(t);if(r)for(let c of r)a(c)};var o=a;let s=e._vode;delete e._vode,Object.defineProperty(s.state,"patch",{value:void 0}),Object.defineProperty(s,"renderSync",{value:()=>{}}),Object.defineProperty(s,"renderAsync",{value:()=>{}}),a(s.vode)}}function D(e,o){if(e?.nodeType===Node.TEXT_NODE)return e.nodeValue?.trim()!==""?o?e:e.nodeValue:void 0;if(e.nodeType===Node.COMMENT_NODE)return;if(e.nodeType===Node.ELEMENT_NODE){let s=[e.tagName.toLowerCase()];if(o&&(s.node=e),e?.hasAttributes()){let t={},n=e.attributes;for(let r of n)t[r.name]=r.value;s.push(t)}if(e.hasChildNodes()){let t=[];for(let n of e.childNodes){let r=n&&D(n,o);r?s.push(r):n&&o&&t.push(n)}for(let n of t)n.remove()}return s}else return}function X(e,o){if(!e||!Array.isArray(e))throw new Error("first argument to memo() must be an array of values to compare");if(typeof o!="function")throw new Error("second argument to memo() must be a function that returns a vode or props object");return o.__memo=e,o}function $(e){if(!e||typeof e!="object")throw new Error("createState() must be called with a state object");return e}function w(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 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 o=v(e);return o>0?e.slice(o):null}function W(e){let o=v(e);return o<0?0:e.length-o}function J(e,o){let a=v(e);if(a>0)return e[o+a]}function v(e){return A(e)?e.length>2?2:-1:Array.isArray(e)&&e.length>1?1:-1}function E(e,o,a){if(!o)return e;for(let s in o){let t=o[s];if(t&&typeof t=="object"){let n=e[s];n?Array.isArray(t)?e[s]=[...t]:t instanceof Date&&n!==t?e[s]=new Date(t):Array.isArray(n)?e[s]=E({},t,a):typeof n=="object"?E(e[s],t,a):e[s]=E({},t,a):Array.isArray(t)?e[s]=[...t]:t instanceof Date?e[s]=new Date(t):e[s]=E({},t,a)}else t===void 0&&a?delete e[s]:e[s]=t}return e}function C(e,o,a,s,t,n,r){try{n=R(e,n,t);let c=!n||typeof n=="number"||typeof n=="boolean";if(n===t||!t&&c)return t;let f=t?.nodeType===Node.TEXT_NODE,i=f?t:t?.node;if(c){i?.onUnmount&&e.patch(i.onUnmount(i)),i?.remove();return}let b=!c&&K(n),p=!c&&G(n),y=!!n&&typeof n!="string"&&!!(n?.node||n?.nodeType===Node.TEXT_NODE);if(!b&&!p&&!y&&!t)throw new Error("Invalid vode: "+typeof n+" "+JSON.stringify(n));if(y&&b?n=n.wholeText:y&&p&&(n=[...n]),f&&b)return i.nodeValue!==n&&(i.nodeValue=n),t;if(b&&(!i||!f)){let l=document.createTextNode(n);if(i)i.onUnmount&&e.patch(i.onUnmount(i)),i.replaceWith(l);else{let S=!1;for(let d=0;d<o.childNodes.length;d++){let g=o.childNodes[s+d];if(g){g.before(l,g),S=!0;break}}S||o.appendChild(l)}return l}if(p&&(!i||f||t[0]!==n[0])){let l=n;1 in l&&(l[1]=R(e,l[1],void 0));let S=A(n);S?.xmlns!==void 0&&(r=S.xmlns);let d=r?document.createElementNS(r,n[0]):document.createElement(n[0]);if(n.node=d,O(e,d,void 0,S,r),S&&"catch"in S&&(n.node.catch=null,n.node.removeAttribute("catch")),i)i.onUnmount&&e.patch(i.onUnmount(i)),i.replaceWith(d);else{let x=!1;for(let T=0;T<o.childNodes.length;T++){let u=o.childNodes[s+T];if(u){u.before(d,u),x=!0;break}}x||o.appendChild(d)}let g=N(n);if(g){let x=S?2:1,T=0;for(let u=0;u<g.length;u++){let h=g[u],m=C(e,d,u,T,void 0,h,r);n[u+x]=m,m&&T++}}return d.onMount&&e.patch(d.onMount(d)),n}if(!f&&p&&t[0]===n[0]){n.node=i;let l=n,S=t,d=A(n),g=A(t);if(d?.xmlns!==void 0&&(r=d.xmlns),l[1]?.__memo){let u=l[1];l[1]=R(e,l[1],S[1]),u!==l[1]&&O(e,i,g,d,r)}else O(e,i,g,d,r);d?.catch&&g?.catch!==d.catch&&(n.node.catch=null,n.node.removeAttribute("catch"));let x=N(n),T=N(t);if(x){let u=d?2:1,h=0;for(let m=0;m<x.length;m++){let H=x[m],U=T&&T[m],L=C(e,i,m,h,U,H,r);n[m+u]=L,L&&h++}}if(T){let u=x?x.length:0;for(let h=T.length-1;h>=u;h--)C(e,i,h,h,T[h],void 0,r)}return n}}catch(c){let f=A(n)?.catch;if(f){let i=typeof f=="function"?f(e,c):f;return C(e,o,a,s,D(n?.node||t?.node,!0),i,r)}else throw c}}function G(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 R(e,o,a){if(typeof o!="function")return o;let s=o?.__memo,t=a?.__memo;if(Array.isArray(s)&&Array.isArray(t)&&s.length===t.length){let r=!0;for(let c=0;c<s.length;c++)if(s[c]!==t[c]){r=!1;break}if(r)return a}let n=I(o,e);return typeof n=="object"&&(n.__memo=o?.__memo),n}function I(e,o){return typeof e=="function"?I(e(o),o):e}function O(e,o,a,s,t){if(!s&&!a)return;let n=t!==void 0;if(a)for(let r in a){let c=a[r],f=s?.[r];c!==f&&(s?s[r]=M(e,o,r,c,f,n):M(e,o,r,c,void 0,n))}if(s&&a){for(let r in s)if(!(r in a)){let c=s[r];s[r]=M(e,o,r,void 0,c,n)}}else if(s)for(let r in s){let c=s[r];s[r]=M(e,o,r,void 0,c,n)}}function M(e,o,a,s,t,n){if(a==="style")if(!t)o.style.cssText="";else if(typeof t=="string")s!==t&&(o.style.cssText=t);else if(s&&typeof s=="object"){for(let r in s)t[r]||(o.style[r]=null);for(let r in t){let c=s[r],f=t[r];c!==f&&(o.style[r]=f)}}else for(let r in t)o.style[r]=t[r];else if(a==="class")t?o.setAttribute("class",V(t)):o.removeAttribute("class");else if(a[0]==="o"&&a[1]==="n")if(t){let r=null;if(typeof t=="function"){let c=t;r=f=>e.patch(c(e,f))}else typeof t=="object"&&(r=()=>e.patch(t));o[a]=r}else o[a]=null;else n||(o[a]=t),t==null||t===!1?o.removeAttribute(a):o.setAttribute(a,t);return t}function V(e){return typeof e=="string"?e:Array.isArray(e)?e.map(V).join(" "):typeof e=="object"?Object.keys(e).filter(o=>e[o]).join(" "):""}var z="a",Z="abbr",tt="address",et="area",nt="article",ot="aside",st="audio",at="b",rt="base",ct="bdi",it="bdo",pt="blockquote",lt="body",dt="br",ft="button",St="canvas",ut="caption",Tt="cite",yt="code",gt="col",xt="colgroup",ht="data",mt="datalist",Et="dd",bt="del",Pt="details",At="dfn",Ct="dialog",Mt="div",Nt="dl",Rt="dt",Ot="em",Dt="embed",vt="fieldset",Lt="figcaption",It="figure",Vt="footer",Ft="form",kt="h1",jt="h2",Ht="h3",Ut="h4",Gt="h5",Kt="h6",Bt="head",_t="header",qt="hgroup",Xt="hr",$t="html",wt="i",Yt="iframe",Wt="img",Jt="input",Qt="ins",zt="kbd",Zt="label",te="legend",ee="li",ne="link",oe="main",se="map",ae="mark",re="menu",ce="meta",ie="meter",pe="nav",le="noscript",de="object",fe="ol",Se="optgroup",ue="option",Te="output",ye="p",ge="picture",xe="pre",he="progress",me="q",Ee="rp",be="rt",Pe="ruby",Ae="s",Ce="samp",Me="script",Ne="search",Re="section",Oe="select",De="slot",ve="small",Le="source",Ie="span",Ve="strong",Fe="style",ke="sub",je="summary",He="sup",Ue="table",Ge="tbody",Ke="td",Be="template",_e="textarea",qe="tfoot",Xe="th",$e="thead",we="time",Ye="title",We="tr",Je="track",Qe="u",ze="ul",Ze="var",tn="video",en="wbr",nn="animate",on="animateMotion",sn="animateTransform",an="circle",rn="clipPath",cn="defs",pn="desc",ln="ellipse",dn="feBlend",fn="feColorMatrix",Sn="feComponentTransfer",un="feComposite",Tn="feConvolveMatrix",yn="feDiffuseLighting",gn="feDisplacementMap",xn="feDistantLight",hn="feDropShadow",mn="feFlood",En="feFuncA",bn="feFuncB",Pn="feFuncG",An="feFuncR",Cn="feGaussianBlur",Mn="feImage",Nn="feMerge",Rn="feMergeNode",On="feMorphology",Dn="feOffset",vn="fePointLight",Ln="feSpecularLighting",In="feSpotLight",Vn="feTile",Fn="feTurbulence",kn="filter",jn="foreignObject",Hn="g",Un="image",Gn="line",Kn="linearGradient",Bn="marker",_n="mask",qn="metadata",Xn="mpath",$n="path",wn="pattern",Yn="polygon",Wn="polyline",Jn="radialGradient",Qn="rect",zn="set",Zn="stop",to="svg",eo="switch",no="symbol",oo="text",so="textPath",ao="tspan",ro="use",co="view",io="annotation",po="annotation-xml",lo="maction",fo="math",So="merror",uo="mfrac",To="mi",yo="mmultiscripts",go="mn",xo="mo",ho="mover",mo="mpadded",Eo="mphantom",bo="mprescripts",Po="mroot",Ao="mrow",Co="ms",Mo="mspace",No="msqrt",Ro="mstyle",Oo="msub",Do="msubsup",vo="msup",Lo="mtable",Io="mtd",Vo="mtext",Fo="mtr",ko="munder",jo="munderover",Ho="semantics";function Go(...e){if(!e||e.length===0)return null;if(e.length===1)return e[0];let o=e[0];for(let a=1;a<e.length;a++){let s=o,t=e[a];if(!s)o=t;else if(t)if(typeof s=="string"&&typeof t=="string"){let n=s.split(" "),r=t.split(" "),c=new Set([...n,...r]);o=Array.from(c).join(" ").trim()}else if(typeof s=="string"&&Array.isArray(t)){let n=new Set([...t,...s.split(" ")]);o=Array.from(n).join(" ").trim()}else if(Array.isArray(s)&&typeof t=="string"){let n=new Set([...s,...t.split(" ")]);o=Array.from(n).join(" ").trim()}else if(Array.isArray(s)&&Array.isArray(t)){let n=new Set([...s,...t]);o=Array.from(n).join(" ").trim()}else if(typeof s=="string"&&typeof t=="object")o={[s]:!0,...t};else if(typeof s=="object"&&typeof t=="string")o={...s,[t]:!0};else if(typeof s=="object"&&typeof t=="object")o={...s,...t};else if(typeof s=="object"&&Array.isArray(t)){let n={...s};for(let r of t)n[r]=!0;o=n}else if(Array.isArray(s)&&typeof t=="object"){let n={};for(let r of s)n[r]=!0;for(let r of Object.keys(t))n[r]=t[r];o=n}else throw new Error(`cannot merge classes of ${s} (${typeof s}) and ${t} (${typeof t})`);else continue}return o}var F=document.createElement("div");function Bo(...e){try{let o=F.style;for(let a of e)if(typeof a=="object"&&a!==null)for(let s in a)o[s]=a[s];else typeof a=="string"&&(o.cssText+=";"+a);return o.cssText}finally{F.style.cssText=""}}var k=class{constructor(o,a){this.state=o;this.path=a;this.keys=a.split(".")}keys;get(){let o=this.keys,a=this.state?this.state[o[0]]:void 0;for(let s=1;s<o.length&&a;s++)a=a[o[s]];return a}put(o){this.putDeep(o,this.state)}patch(o){if(Array.isArray(o)){let a=[];for(let s of o)a.push(this.createPatch(s));this.state.patch(a)}else this.state.patch(this.createPatch(o))}createPatch(o){let a={};return this.putDeep(o,a),a}putDeep(o,a){let s=this.keys;if(s.length>1){let t=0,n=a[s[t]];for((typeof n!="object"||n===null)&&(a[s[t]]=n={}),t=1;t<s.length-1;t++){let r=n;n=n[s[t]],(typeof n!="object"||n===null)&&(r[s[t]]=n={})}n[s[t]]=o}else typeof a[s[0]]=="object"&&typeof o=="object"?Object.assign(a[s[0]],o):a[s[0]]=o}},j=class{constructor(o,a,s,t){this.state=o;this.get=a;this.put=s;this.patch=t}};export{z as A,Z as ABBR,tt as ADDRESS,nn as ANIMATE,on as ANIMATEMOTION,sn as ANIMATETRANSFORM,io as ANNOTATION,po as ANNOTATION_XML,et as AREA,nt as ARTICLE,ot as ASIDE,st as AUDIO,at as B,rt as BASE,ct as BDI,it as BDO,pt as BLOCKQUOTE,lt as BODY,dt as BR,ft as BUTTON,St as CANVAS,ut as CAPTION,an as CIRCLE,Tt as CITE,rn as CLIPPATH,yt as CODE,gt as COL,xt as COLGROUP,ht as DATA,mt as DATALIST,Et as DD,cn as DEFS,bt as DEL,pn as DESC,Pt as DETAILS,At as DFN,Ct as DIALOG,Mt as DIV,Nt as DL,Rt as DT,j as DelegateStateContext,ln as ELLIPSE,Ot as EM,Dt as EMBED,dn as FEBLEND,fn as FECOLORMATRIX,Sn as FECOMPONENTTRANSFER,un as FECOMPOSITE,Tn as FECONVOLVEMATRIX,yn as FEDIFFUSELIGHTING,gn as FEDISPLACEMENTMAP,xn as FEDISTANTLIGHT,hn as FEDROPSHADOW,mn as FEFLOOD,En as FEFUNCA,bn as FEFUNCB,Pn as FEFUNCG,An as FEFUNCR,Cn as FEGAUSSIANBLUR,Mn as FEIMAGE,Nn as FEMERGE,Rn 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,kn as FILTER,Vt as FOOTER,jn as FOREIGNOBJECT,Ft as FORM,Hn as G,kt as H1,jt as H2,Ht as H3,Ut as H4,Gt as H5,Kt as H6,Bt as HEAD,_t as HEADER,qt as HGROUP,Xt as HR,$t as HTML,wt as I,Yt as IFRAME,Un as IMAGE,Wt as IMG,Jt as INPUT,Qt as INS,zt as KBD,k as KeyStateContext,Zt as LABEL,te as LEGEND,ee as LI,Gn as LINE,Kn as LINEARGRADIENT,ne as LINK,lo as MACTION,oe as MAIN,se as MAP,ae as MARK,Bn as MARKER,_n as MASK,fo as MATH,re as MENU,So as MERROR,ce as META,qn as METADATA,ie as METER,uo as MFRAC,To as MI,yo as MMULTISCRIPTS,go as MN,xo as MO,ho as MOVER,mo as MPADDED,Xn as MPATH,Eo as MPHANTOM,bo as MPRESCRIPTS,Po as MROOT,Ao as MROW,Co as MS,Mo as MSPACE,No as MSQRT,Ro as MSTYLE,Oo as MSUB,Do as MSUBSUP,vo as MSUP,Lo as MTABLE,Io as MTD,Vo as MTEXT,Fo as MTR,ko as MUNDER,jo as MUNDEROVER,pe as NAV,le as NOSCRIPT,de as OBJECT,fe as OL,Se as OPTGROUP,ue as OPTION,Te as OUTPUT,ye as P,$n as PATH,wn as PATTERN,ge as PICTURE,Yn as POLYGON,Wn as POLYLINE,xe as PRE,he as PROGRESS,me as Q,Jn as RADIALGRADIENT,Qn as RECT,Ee as RP,be as RT,Pe as RUBY,Ae as S,Ce as SAMP,Me as SCRIPT,Ne as SEARCH,Re as SECTION,Oe as SELECT,Ho 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,ke as SUB,je as SUMMARY,He as SUP,to as SVG,eo as SWITCH,no as SYMBOL,Ue as TABLE,Ge as TBODY,Ke as TD,Be as TEMPLATE,oo as TEXT,_e as TEXTAREA,so as TEXTPATH,qe as TFOOT,Xe as TH,$e as THEAD,we as TIME,Ye as TITLE,We as TR,Je as TRACK,ao as TSPAN,Qe as U,ze as UL,ro as USE,Ze as VAR,tn as VIDEO,co as VIEW,en as WBR,_ as app,J as child,W as childCount,N as children,v as childrenStart,w as createPatch,$ as createState,q as defuse,P as globals,D as hydrate,X as memo,Go as mergeClass,Bo as mergeStyle,A as props,Y as tag,B as vode};
|
package/dist/vode.mjs
CHANGED
|
@@ -87,7 +87,7 @@ function app(container, state, dom, ...initialPatches) {
|
|
|
87
87
|
function renderDom(isAsync) {
|
|
88
88
|
const sw = Date.now();
|
|
89
89
|
const vom = dom(_vode.state);
|
|
90
|
-
_vode.vode = render(_vode.state, container.parentElement, 0, _vode.vode, vom);
|
|
90
|
+
_vode.vode = render(_vode.state, container.parentElement, 0, 0, _vode.vode, vom);
|
|
91
91
|
if (container.tagName.toUpperCase() !== vom[0].toUpperCase()) {
|
|
92
92
|
container = _vode.vode.node;
|
|
93
93
|
container._vode = _vode;
|
|
@@ -139,10 +139,12 @@ function app(container, state, dom, ...initialPatches) {
|
|
|
139
139
|
_vode.state = patchableState;
|
|
140
140
|
const root = container;
|
|
141
141
|
root._vode = _vode;
|
|
142
|
+
const indexInParent = Array.from(container.parentElement.children).indexOf(container);
|
|
142
143
|
_vode.vode = render(
|
|
143
144
|
state,
|
|
144
145
|
container.parentElement,
|
|
145
|
-
|
|
146
|
+
indexInParent,
|
|
147
|
+
indexInParent,
|
|
146
148
|
hydrate(container, true),
|
|
147
149
|
dom(state)
|
|
148
150
|
);
|
|
@@ -292,7 +294,7 @@ function mergeState(target, source, allowDeletion) {
|
|
|
292
294
|
}
|
|
293
295
|
return target;
|
|
294
296
|
}
|
|
295
|
-
function render(state, parent, childIndex, oldVode, newVode, xmlns) {
|
|
297
|
+
function render(state, parent, childIndex, indexInParent, oldVode, newVode, xmlns) {
|
|
296
298
|
try {
|
|
297
299
|
newVode = remember(state, newVode, oldVode);
|
|
298
300
|
const isNoVode = !newVode || typeof newVode === "number" || typeof newVode === "boolean";
|
|
@@ -328,9 +330,16 @@ function render(state, parent, childIndex, oldVode, newVode, xmlns) {
|
|
|
328
330
|
oldNode.onUnmount && state.patch(oldNode.onUnmount(oldNode));
|
|
329
331
|
oldNode.replaceWith(text);
|
|
330
332
|
} else {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
333
|
+
let inserted = false;
|
|
334
|
+
for (let i = 0; i < parent.childNodes.length; i++) {
|
|
335
|
+
const nextSibling = parent.childNodes[indexInParent + i];
|
|
336
|
+
if (nextSibling) {
|
|
337
|
+
nextSibling.before(text, nextSibling);
|
|
338
|
+
inserted = true;
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
if (!inserted) {
|
|
334
343
|
parent.appendChild(text);
|
|
335
344
|
}
|
|
336
345
|
}
|
|
@@ -342,10 +351,10 @@ function render(state, parent, childIndex, oldVode, newVode, xmlns) {
|
|
|
342
351
|
newvode[1] = remember(state, newvode[1], void 0);
|
|
343
352
|
}
|
|
344
353
|
const properties = props(newVode);
|
|
345
|
-
|
|
354
|
+
if (properties?.xmlns !== void 0) xmlns = properties.xmlns;
|
|
346
355
|
const newNode = xmlns ? document.createElementNS(xmlns, newVode[0]) : document.createElement(newVode[0]);
|
|
347
356
|
newVode.node = newNode;
|
|
348
|
-
patchProperties(state, newNode, void 0, properties);
|
|
357
|
+
patchProperties(state, newNode, void 0, properties, xmlns);
|
|
349
358
|
if (!!properties && "catch" in properties) {
|
|
350
359
|
newVode.node["catch"] = null;
|
|
351
360
|
newVode.node.removeAttribute("catch");
|
|
@@ -354,18 +363,28 @@ function render(state, parent, childIndex, oldVode, newVode, xmlns) {
|
|
|
354
363
|
oldNode.onUnmount && state.patch(oldNode.onUnmount(oldNode));
|
|
355
364
|
oldNode.replaceWith(newNode);
|
|
356
365
|
} else {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
366
|
+
let inserted = false;
|
|
367
|
+
for (let i = 0; i < parent.childNodes.length; i++) {
|
|
368
|
+
const nextSibling = parent.childNodes[indexInParent + i];
|
|
369
|
+
if (nextSibling) {
|
|
370
|
+
nextSibling.before(newNode, nextSibling);
|
|
371
|
+
inserted = true;
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (!inserted) {
|
|
360
376
|
parent.appendChild(newNode);
|
|
361
377
|
}
|
|
362
378
|
}
|
|
363
|
-
const
|
|
364
|
-
if (
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
379
|
+
const newKids = children(newVode);
|
|
380
|
+
if (newKids) {
|
|
381
|
+
const childOffset = !!properties ? 2 : 1;
|
|
382
|
+
let indexP = 0;
|
|
383
|
+
for (let i = 0; i < newKids.length; i++) {
|
|
384
|
+
const child2 = newKids[i];
|
|
385
|
+
const attached = render(state, newNode, i, indexP, void 0, child2, xmlns);
|
|
386
|
+
newVode[i + childOffset] = attached;
|
|
387
|
+
if (attached) indexP++;
|
|
369
388
|
}
|
|
370
389
|
}
|
|
371
390
|
newNode.onMount && state.patch(newNode.onMount(newNode));
|
|
@@ -376,16 +395,16 @@ function render(state, parent, childIndex, oldVode, newVode, xmlns) {
|
|
|
376
395
|
const newvode = newVode;
|
|
377
396
|
const oldvode = oldVode;
|
|
378
397
|
const properties = props(newVode);
|
|
379
|
-
let hasProps = !!properties;
|
|
380
398
|
const oldProps = props(oldVode);
|
|
399
|
+
if (properties?.xmlns !== void 0) xmlns = properties.xmlns;
|
|
381
400
|
if (newvode[1]?.__memo) {
|
|
382
401
|
const prev = newvode[1];
|
|
383
402
|
newvode[1] = remember(state, newvode[1], oldvode[1]);
|
|
384
403
|
if (prev !== newvode[1]) {
|
|
385
|
-
patchProperties(state, oldNode, oldProps, properties);
|
|
404
|
+
patchProperties(state, oldNode, oldProps, properties, xmlns);
|
|
386
405
|
}
|
|
387
406
|
} else {
|
|
388
|
-
patchProperties(state, oldNode, oldProps, properties);
|
|
407
|
+
patchProperties(state, oldNode, oldProps, properties, xmlns);
|
|
389
408
|
}
|
|
390
409
|
if (!!properties?.catch && oldProps?.catch !== properties.catch) {
|
|
391
410
|
newVode.node["catch"] = null;
|
|
@@ -394,19 +413,20 @@ function render(state, parent, childIndex, oldVode, newVode, xmlns) {
|
|
|
394
413
|
const newKids = children(newVode);
|
|
395
414
|
const oldKids = children(oldVode);
|
|
396
415
|
if (newKids) {
|
|
416
|
+
const childOffset = !!properties ? 2 : 1;
|
|
417
|
+
let indexP = 0;
|
|
397
418
|
for (let i = 0; i < newKids.length; i++) {
|
|
398
419
|
const child2 = newKids[i];
|
|
399
420
|
const oldChild = oldKids && oldKids[i];
|
|
400
|
-
const attached = render(state, oldNode, i, oldChild, child2, xmlns);
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
}
|
|
421
|
+
const attached = render(state, oldNode, i, indexP, oldChild, child2, xmlns);
|
|
422
|
+
newVode[i + childOffset] = attached;
|
|
423
|
+
if (attached) indexP++;
|
|
404
424
|
}
|
|
405
425
|
}
|
|
406
426
|
if (oldKids) {
|
|
407
427
|
const newKidsCount = newKids ? newKids.length : 0;
|
|
408
428
|
for (let i = oldKids.length - 1; i >= newKidsCount; i--) {
|
|
409
|
-
render(state, oldNode, i, oldKids[i], void 0, xmlns);
|
|
429
|
+
render(state, oldNode, i, i, oldKids[i], void 0, xmlns);
|
|
410
430
|
}
|
|
411
431
|
}
|
|
412
432
|
return newVode;
|
|
@@ -419,6 +439,7 @@ function render(state, parent, childIndex, oldVode, newVode, xmlns) {
|
|
|
419
439
|
state,
|
|
420
440
|
parent,
|
|
421
441
|
childIndex,
|
|
442
|
+
indexInParent,
|
|
422
443
|
hydrate(newVode?.node || oldVode?.node, true),
|
|
423
444
|
handledVode,
|
|
424
445
|
xmlns
|
|
@@ -463,15 +484,18 @@ function unwrap(c, s) {
|
|
|
463
484
|
return c;
|
|
464
485
|
}
|
|
465
486
|
}
|
|
466
|
-
function patchProperties(s, node, oldProps, newProps) {
|
|
487
|
+
function patchProperties(s, node, oldProps, newProps, xmlns) {
|
|
467
488
|
if (!newProps && !oldProps) return;
|
|
489
|
+
const xmlMode = xmlns !== void 0;
|
|
468
490
|
if (oldProps) {
|
|
469
491
|
for (const key in oldProps) {
|
|
470
492
|
const oldValue = oldProps[key];
|
|
471
493
|
const newValue = newProps?.[key];
|
|
472
494
|
if (oldValue !== newValue) {
|
|
473
|
-
if (newProps)
|
|
474
|
-
|
|
495
|
+
if (newProps)
|
|
496
|
+
newProps[key] = patchProperty(s, node, key, oldValue, newValue, xmlMode);
|
|
497
|
+
else
|
|
498
|
+
patchProperty(s, node, key, oldValue, void 0, xmlMode);
|
|
475
499
|
}
|
|
476
500
|
}
|
|
477
501
|
}
|
|
@@ -479,17 +503,17 @@ function patchProperties(s, node, oldProps, newProps) {
|
|
|
479
503
|
for (const key in newProps) {
|
|
480
504
|
if (!(key in oldProps)) {
|
|
481
505
|
const newValue = newProps[key];
|
|
482
|
-
newProps[key] = patchProperty(s, node, key, void 0, newValue);
|
|
506
|
+
newProps[key] = patchProperty(s, node, key, void 0, newValue, xmlMode);
|
|
483
507
|
}
|
|
484
508
|
}
|
|
485
509
|
} else if (newProps) {
|
|
486
510
|
for (const key in newProps) {
|
|
487
511
|
const newValue = newProps[key];
|
|
488
|
-
newProps[key] = patchProperty(s, node, key, void 0, newValue);
|
|
512
|
+
newProps[key] = patchProperty(s, node, key, void 0, newValue, xmlMode);
|
|
489
513
|
}
|
|
490
514
|
}
|
|
491
515
|
}
|
|
492
|
-
function patchProperty(s, node, key, oldValue, newValue) {
|
|
516
|
+
function patchProperty(s, node, key, oldValue, newValue, xmlMode) {
|
|
493
517
|
if (key === "style") {
|
|
494
518
|
if (!newValue) {
|
|
495
519
|
node.style.cssText = "";
|
|
@@ -534,7 +558,7 @@ function patchProperty(s, node, key, oldValue, newValue) {
|
|
|
534
558
|
node[key] = null;
|
|
535
559
|
}
|
|
536
560
|
} else {
|
|
537
|
-
node[key] = newValue;
|
|
561
|
+
if (!xmlMode) node[key] = newValue;
|
|
538
562
|
if (newValue === void 0 || newValue === null || newValue === false)
|
|
539
563
|
node.removeAttribute(key);
|
|
540
564
|
else
|
package/package.json
CHANGED
package/src/vode.ts
CHANGED
|
@@ -33,6 +33,7 @@ export type Props<S> = Partial<
|
|
|
33
33
|
{ [K in keyof EventsMap]: EventFunction<S> | Patch<S> } // all on* events
|
|
34
34
|
> & {
|
|
35
35
|
[_: string]: unknown,
|
|
36
|
+
xmlns?: string | null,
|
|
36
37
|
class?: ClassProp,
|
|
37
38
|
style?: StyleProp,
|
|
38
39
|
/** called after the element was attached */
|
|
@@ -212,7 +213,7 @@ export function app<S extends PatchableState = PatchableState>(
|
|
|
212
213
|
function renderDom(isAsync: boolean) {
|
|
213
214
|
const sw = Date.now();
|
|
214
215
|
const vom = dom(_vode.state);
|
|
215
|
-
_vode.vode = render<S>(_vode.state, container.parentElement as Element, 0, _vode.vode, vom)!;
|
|
216
|
+
_vode.vode = render<S>(_vode.state, container.parentElement as Element, 0, 0, _vode.vode, vom)!;
|
|
216
217
|
|
|
217
218
|
if ((<ContainerNode<S>>container).tagName.toUpperCase() !== (vom[0] as Tag).toUpperCase()) { //the tag name was changed during render -> update reference to vode-app-root
|
|
218
219
|
container = _vode.vode.node as Element;
|
|
@@ -272,11 +273,12 @@ export function app<S extends PatchableState = PatchableState>(
|
|
|
272
273
|
|
|
273
274
|
const root = container as ContainerNode<S>;
|
|
274
275
|
root._vode = _vode;
|
|
275
|
-
|
|
276
|
+
const indexInParent = Array.from(container.parentElement.children).indexOf(container);
|
|
276
277
|
_vode.vode = render(
|
|
277
278
|
<S>state,
|
|
278
279
|
container.parentElement,
|
|
279
|
-
|
|
280
|
+
indexInParent,
|
|
281
|
+
indexInParent,
|
|
280
282
|
hydrate<S>(container, true) as AttachedVode<S>,
|
|
281
283
|
dom(<S>state)
|
|
282
284
|
)!;
|
|
@@ -471,7 +473,7 @@ function mergeState(target: any, source: any, allowDeletion: boolean) {
|
|
|
471
473
|
return target;
|
|
472
474
|
};
|
|
473
475
|
|
|
474
|
-
function render<S extends PatchableState>(state: S, parent: Element, childIndex: number, oldVode: AttachedVode<S> | undefined, newVode: ChildVode<S>, xmlns?: string): AttachedVode<S> | undefined {
|
|
476
|
+
function render<S extends PatchableState>(state: S, parent: Element, childIndex: number, indexInParent: number, oldVode: AttachedVode<S> | undefined, newVode: ChildVode<S>, xmlns?: string | null): AttachedVode<S> | undefined {
|
|
475
477
|
try {
|
|
476
478
|
// unwrap component if it is memoized
|
|
477
479
|
newVode = remember(state, newVode, oldVode) as ChildVode<S>;
|
|
@@ -519,9 +521,16 @@ function render<S extends PatchableState>(state: S, parent: Element, childIndex:
|
|
|
519
521
|
(<any>oldNode).onUnmount && state.patch((<any>oldNode).onUnmount(oldNode));
|
|
520
522
|
oldNode.replaceWith(text);
|
|
521
523
|
} else {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
524
|
+
let inserted = false;
|
|
525
|
+
for (let i = 0; i < parent.childNodes.length; i++) {
|
|
526
|
+
const nextSibling = parent.childNodes[indexInParent + i];
|
|
527
|
+
if (nextSibling) {
|
|
528
|
+
nextSibling.before(text, nextSibling);
|
|
529
|
+
inserted = true;
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
if (!inserted) {
|
|
525
534
|
parent.appendChild(text);
|
|
526
535
|
}
|
|
527
536
|
}
|
|
@@ -539,13 +548,14 @@ function render<S extends PatchableState>(state: S, parent: Element, childIndex:
|
|
|
539
548
|
|
|
540
549
|
const properties = props(newVode);
|
|
541
550
|
|
|
542
|
-
|
|
551
|
+
if (properties?.xmlns !== undefined) xmlns = properties.xmlns;
|
|
552
|
+
|
|
543
553
|
const newNode: ChildNode = xmlns
|
|
544
554
|
? document.createElementNS(xmlns, (<Vode<S>>newVode)[0])
|
|
545
555
|
: document.createElement((<Vode<S>>newVode)[0]);
|
|
546
556
|
(<AttachedVode<S>>newVode).node = newNode;
|
|
547
557
|
|
|
548
|
-
patchProperties(state, newNode, undefined, properties);
|
|
558
|
+
patchProperties(state, newNode, undefined, properties, xmlns);
|
|
549
559
|
|
|
550
560
|
if (!!properties && 'catch' in properties) {
|
|
551
561
|
(<any>newVode).node['catch'] = null;
|
|
@@ -556,19 +566,29 @@ function render<S extends PatchableState>(state: S, parent: Element, childIndex:
|
|
|
556
566
|
(<any>oldNode).onUnmount && state.patch((<any>oldNode).onUnmount(oldNode));
|
|
557
567
|
oldNode.replaceWith(newNode);
|
|
558
568
|
} else {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
569
|
+
let inserted = false;
|
|
570
|
+
for (let i = 0; i < parent.childNodes.length; i++) {
|
|
571
|
+
const nextSibling = parent.childNodes[indexInParent + i];
|
|
572
|
+
if (nextSibling) {
|
|
573
|
+
nextSibling.before(newNode, nextSibling);
|
|
574
|
+
inserted = true;
|
|
575
|
+
break;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
if (!inserted) {
|
|
562
579
|
parent.appendChild(newNode);
|
|
563
580
|
}
|
|
564
581
|
}
|
|
565
582
|
|
|
566
|
-
const
|
|
567
|
-
if (
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
583
|
+
const newKids = children(newVode);
|
|
584
|
+
if (newKids) {
|
|
585
|
+
const childOffset = !!properties ? 2 : 1;
|
|
586
|
+
let indexP = 0;
|
|
587
|
+
for (let i = 0; i < newKids.length; i++) {
|
|
588
|
+
const child = newKids[i];
|
|
589
|
+
const attached = render(state, newNode as Element, i, indexP, undefined, child, xmlns);
|
|
590
|
+
(<Vode<S>>newVode!)[i + childOffset] = <Vode<S>>attached;
|
|
591
|
+
if (attached) indexP++;
|
|
572
592
|
}
|
|
573
593
|
}
|
|
574
594
|
|
|
@@ -584,18 +604,19 @@ function render<S extends PatchableState>(state: S, parent: Element, childIndex:
|
|
|
584
604
|
const oldvode = <Vode<S>>oldVode;
|
|
585
605
|
|
|
586
606
|
const properties = props(newVode);
|
|
587
|
-
let hasProps = !!properties;
|
|
588
607
|
const oldProps = props(oldVode);
|
|
589
608
|
|
|
609
|
+
if (properties?.xmlns !== undefined) xmlns = properties.xmlns;
|
|
610
|
+
|
|
590
611
|
if ((<any>newvode[1])?.__memo) {
|
|
591
612
|
const prev = newvode[1] as any;
|
|
592
613
|
newvode[1] = remember(state, newvode[1], oldvode[1]) as Vode<S>;
|
|
593
614
|
if (prev !== newvode[1]) {
|
|
594
|
-
patchProperties(state, oldNode!, oldProps, properties);
|
|
615
|
+
patchProperties(state, oldNode!, oldProps, properties, xmlns);
|
|
595
616
|
}
|
|
596
617
|
}
|
|
597
618
|
else {
|
|
598
|
-
patchProperties(state, oldNode!, oldProps, properties);
|
|
619
|
+
patchProperties(state, oldNode!, oldProps, properties, xmlns);
|
|
599
620
|
}
|
|
600
621
|
|
|
601
622
|
if (!!properties?.catch && oldProps?.catch !== properties.catch) {
|
|
@@ -606,21 +627,22 @@ function render<S extends PatchableState>(state: S, parent: Element, childIndex:
|
|
|
606
627
|
const newKids = children(newVode);
|
|
607
628
|
const oldKids = children(oldVode) as AttachedVode<S>[];
|
|
608
629
|
if (newKids) {
|
|
630
|
+
const childOffset = !!properties ? 2 : 1;
|
|
631
|
+
let indexP = 0;
|
|
609
632
|
for (let i = 0; i < newKids.length; i++) {
|
|
610
633
|
const child = newKids[i];
|
|
611
634
|
const oldChild = oldKids && oldKids[i];
|
|
612
635
|
|
|
613
|
-
const attached = render(state, oldNode as Element, i, oldChild, child, xmlns);
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
}
|
|
636
|
+
const attached = render(state, oldNode as Element, i, indexP, oldChild, child, xmlns);
|
|
637
|
+
(<Vode<S>>newVode)[i + childOffset] = <Vode<S>>attached;
|
|
638
|
+
if (attached) indexP++;
|
|
617
639
|
}
|
|
618
640
|
}
|
|
619
641
|
|
|
620
642
|
if (oldKids) {
|
|
621
643
|
const newKidsCount = newKids ? newKids.length : 0;
|
|
622
644
|
for (let i = oldKids.length - 1; i >= newKidsCount; i--) {
|
|
623
|
-
render(state, oldNode as Element, i, oldKids[i], undefined, xmlns);
|
|
645
|
+
render(state, oldNode as Element, i, i, oldKids[i], undefined, xmlns);
|
|
624
646
|
}
|
|
625
647
|
}
|
|
626
648
|
|
|
@@ -633,7 +655,7 @@ function render<S extends PatchableState>(state: S, parent: Element, childIndex:
|
|
|
633
655
|
? (<(s: S, error: any) => ChildVode<S>>catchVode)(state, error)
|
|
634
656
|
: catchVode;
|
|
635
657
|
|
|
636
|
-
return render(state, parent, childIndex,
|
|
658
|
+
return render(state, parent, childIndex, indexInParent,
|
|
637
659
|
hydrate(((<AttachedVode<S>>newVode)?.node || oldVode?.node) as Element, true) as AttachedVode<S>,
|
|
638
660
|
handledVode,
|
|
639
661
|
xmlns);
|
|
@@ -688,9 +710,15 @@ function unwrap<S>(c: Component<S> | ChildVode<S>, s: S): ChildVode<S> {
|
|
|
688
710
|
}
|
|
689
711
|
}
|
|
690
712
|
|
|
691
|
-
function patchProperties<S extends PatchableState>(
|
|
713
|
+
function patchProperties<S extends PatchableState>(
|
|
714
|
+
s: S, node: ChildNode,
|
|
715
|
+
oldProps: Props<S> | null | undefined, newProps: Props<S> | null | undefined,
|
|
716
|
+
xmlns: string | null | undefined
|
|
717
|
+
) {
|
|
692
718
|
if (!newProps && !oldProps) return;
|
|
693
719
|
|
|
720
|
+
const xmlMode = xmlns !== undefined;
|
|
721
|
+
|
|
694
722
|
// match existing properties
|
|
695
723
|
if (oldProps) {
|
|
696
724
|
for (const key in oldProps) {
|
|
@@ -698,8 +726,10 @@ function patchProperties<S extends PatchableState>(s: S, node: ChildNode, oldPro
|
|
|
698
726
|
const newValue = newProps?.[key as keyof Props<S>] as PropertyValue<S>;
|
|
699
727
|
|
|
700
728
|
if (oldValue !== newValue) {
|
|
701
|
-
if (newProps)
|
|
702
|
-
|
|
729
|
+
if (newProps)
|
|
730
|
+
newProps[key as keyof Props<S>] = patchProperty(s, node, key, oldValue, newValue, xmlMode);
|
|
731
|
+
else
|
|
732
|
+
patchProperty(s, node, key, oldValue, undefined, xmlMode);
|
|
703
733
|
}
|
|
704
734
|
}
|
|
705
735
|
}
|
|
@@ -709,7 +739,7 @@ function patchProperties<S extends PatchableState>(s: S, node: ChildNode, oldPro
|
|
|
709
739
|
for (const key in newProps) {
|
|
710
740
|
if (!(key in oldProps)) {
|
|
711
741
|
const newValue = newProps[key as keyof Props<S>] as PropertyValue<S>;
|
|
712
|
-
newProps[key as keyof Props<S>] = patchProperty(s, <Element>node, key, undefined, newValue);
|
|
742
|
+
newProps[key as keyof Props<S>] = patchProperty(s, <Element>node, key, undefined, newValue, xmlMode);
|
|
713
743
|
}
|
|
714
744
|
}
|
|
715
745
|
}
|
|
@@ -717,12 +747,12 @@ function patchProperties<S extends PatchableState>(s: S, node: ChildNode, oldPro
|
|
|
717
747
|
else if (newProps) {
|
|
718
748
|
for (const key in newProps) {
|
|
719
749
|
const newValue = newProps[key as keyof Props<S>] as PropertyValue<S>;
|
|
720
|
-
newProps[key as keyof Props<S>] = patchProperty(s, <Element>node, key, undefined, newValue);
|
|
750
|
+
newProps[key as keyof Props<S>] = patchProperty(s, <Element>node, key, undefined, newValue, xmlMode);
|
|
721
751
|
}
|
|
722
752
|
}
|
|
723
753
|
}
|
|
724
754
|
|
|
725
|
-
function patchProperty<S extends PatchableState>(s: S, node: ChildNode, key: string | keyof ElementEventMap, oldValue
|
|
755
|
+
function patchProperty<S extends PatchableState>(s: S, node: ChildNode, key: string | keyof ElementEventMap, oldValue: PropertyValue<S>, newValue: PropertyValue<S>, xmlMode: boolean) {
|
|
726
756
|
if (key === "style") {
|
|
727
757
|
if (!newValue) {
|
|
728
758
|
(node as HTMLElement).style.cssText = "";
|
|
@@ -768,7 +798,7 @@ function patchProperty<S extends PatchableState>(s: S, node: ChildNode, key: str
|
|
|
768
798
|
(<any>node)[key] = null;
|
|
769
799
|
}
|
|
770
800
|
} else {
|
|
771
|
-
(<any>node)[key] = newValue;
|
|
801
|
+
if (!xmlMode) (<any>node)[key] = newValue;
|
|
772
802
|
if (newValue === undefined || newValue === null || newValue === false)
|
|
773
803
|
(<HTMLElement>node).removeAttribute(key);
|
|
774
804
|
else
|