@ryupold/vode 1.5.2 → 1.6.1

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/README.md CHANGED
@@ -503,6 +503,10 @@ mergeClass('foo', ['baz', 'bar']); // -> 'foo baz bar'
503
503
  mergeClass(['foo'], { bar: true, baz: false }); // -> 'foo bar'
504
504
  mergeClass({zig: true, zag: false}, 'foo', ['baz', 'bar']); // -> 'zig foo baz bar'
505
505
 
506
+ // Merge style props intelligently
507
+ mergeStyle({ color: 'red' }, 'font-weight: bold;'); // -> 'color: red; font-weight: bold;'
508
+ mergeStyle('color: white; background-color: blue;', { marginTop: '10px', color: 'green' }); // -> 'background-color: blue; margin-top: 10px; color: green;'
509
+
506
510
  const myVode = [DIV, { class: 'foo' }, [SPAN, 'hello'], [STRONG, 'world']];
507
511
 
508
512
  // access parts of a vode
package/dist/vode.js CHANGED
@@ -236,6 +236,7 @@ var V = (() => {
236
236
  hydrate: () => hydrate,
237
237
  memo: () => memo,
238
238
  mergeClass: () => mergeClass,
239
+ mergeStyle: () => mergeStyle,
239
240
  props: () => props,
240
241
  tag: () => tag,
241
242
  vode: () => vode
@@ -263,6 +264,7 @@ var V = (() => {
263
264
  _vode.qSync = null;
264
265
  _vode.qAsync = null;
265
266
  _vode.stats = { lastSyncRenderTime: 0, lastAsyncRenderTime: 0, syncRenderCount: 0, asyncRenderCount: 0, liveEffectCount: 0, patchCount: 0, syncRenderPatchCount: 0, asyncRenderPatchCount: 0 };
267
+ const patchableState = state;
266
268
  Object.defineProperty(state, "patch", {
267
269
  enumerable: false,
268
270
  configurable: true,
@@ -278,28 +280,28 @@ var V = (() => {
278
280
  while (v.done === false) {
279
281
  _vode.stats.liveEffectCount++;
280
282
  try {
281
- _vode.patch(v.value, isAsync);
283
+ patchableState.patch(v.value, isAsync);
282
284
  v = await generator.next();
283
285
  } finally {
284
286
  _vode.stats.liveEffectCount--;
285
287
  }
286
288
  }
287
- _vode.patch(v.value, isAsync);
289
+ patchableState.patch(v.value, isAsync);
288
290
  } finally {
289
291
  _vode.stats.liveEffectCount--;
290
292
  }
291
293
  } else if (action.then) {
292
294
  _vode.stats.liveEffectCount++;
293
295
  try {
294
- const nextState = await action;
295
- _vode.patch(nextState, isAsync);
296
+ const resolvedPatch = await action;
297
+ patchableState.patch(resolvedPatch, isAsync);
296
298
  } finally {
297
299
  _vode.stats.liveEffectCount--;
298
300
  }
299
301
  } else if (Array.isArray(action)) {
300
302
  if (action.length > 0) {
301
303
  for (const p of action) {
302
- _vode.patch(p, !document.hidden && !!_vode.asyncRenderer);
304
+ patchableState.patch(p, !document.hidden && !!_vode.asyncRenderer);
303
305
  }
304
306
  } else {
305
307
  _vode.qSync = mergeState(_vode.qSync || {}, _vode.qAsync, false);
@@ -312,7 +314,7 @@ var V = (() => {
312
314
  _vode.renderSync();
313
315
  }
314
316
  } else if (typeof action === "function") {
315
- _vode.patch(action(_vode.state), isAsync);
317
+ patchableState.patch(action(_vode.state), isAsync);
316
318
  } else {
317
319
  if (isAsync) {
318
320
  _vode.stats.asyncRenderPatchCount++;
@@ -329,7 +331,7 @@ var V = (() => {
329
331
  function renderDom(isAsync) {
330
332
  const sw = Date.now();
331
333
  const vom = dom(_vode.state);
332
- _vode.vode = render(_vode.state, _vode.patch, container.parentElement, 0, _vode.vode, vom);
334
+ _vode.vode = render(_vode.state, container.parentElement, 0, _vode.vode, vom);
333
335
  if (container.tagName.toUpperCase() !== vom[0].toUpperCase()) {
334
336
  container = _vode.vode.node;
335
337
  container._vode = _vode;
@@ -378,22 +380,20 @@ var V = (() => {
378
380
  if (_vode.qAsync) _vode.renderAsync();
379
381
  }
380
382
  });
381
- _vode.patch = state.patch;
382
- _vode.state = state;
383
+ _vode.state = patchableState;
383
384
  const root = container;
384
385
  root._vode = _vode;
385
386
  _vode.vode = render(
386
387
  state,
387
- _vode.patch,
388
388
  container.parentElement,
389
389
  Array.from(container.parentElement.children).indexOf(container),
390
390
  hydrate(container, true),
391
391
  dom(state)
392
392
  );
393
393
  for (const effect of initialPatches) {
394
- _vode.patch(effect);
394
+ patchableState.patch(effect);
395
395
  }
396
- return _vode.patch;
396
+ return (action) => patchableState.patch(action);
397
397
  }
398
398
  function defuse(container) {
399
399
  if (container?._vode) {
@@ -536,7 +536,7 @@ var V = (() => {
536
536
  }
537
537
  return target;
538
538
  }
539
- function render(state, patch, parent, childIndex, oldVode, newVode, xmlns) {
539
+ function render(state, parent, childIndex, oldVode, newVode, xmlns) {
540
540
  try {
541
541
  newVode = remember(state, newVode, oldVode);
542
542
  const isNoVode = !newVode || typeof newVode === "number" || typeof newVode === "boolean";
@@ -546,7 +546,7 @@ var V = (() => {
546
546
  const oldIsText = oldVode?.nodeType === Node.TEXT_NODE;
547
547
  const oldNode = oldIsText ? oldVode : oldVode?.node;
548
548
  if (isNoVode) {
549
- oldNode?.onUnmount && patch(oldNode.onUnmount(oldNode));
549
+ oldNode?.onUnmount && state.patch(oldNode.onUnmount(oldNode));
550
550
  oldNode?.remove();
551
551
  return void 0;
552
552
  }
@@ -569,7 +569,7 @@ var V = (() => {
569
569
  if (isText && (!oldNode || !oldIsText)) {
570
570
  const text = document.createTextNode(newVode);
571
571
  if (oldNode) {
572
- oldNode.onUnmount && patch(oldNode.onUnmount(oldNode));
572
+ oldNode.onUnmount && state.patch(oldNode.onUnmount(oldNode));
573
573
  oldNode.replaceWith(text);
574
574
  } else {
575
575
  if (parent.childNodes[childIndex]) {
@@ -586,16 +586,16 @@ var V = (() => {
586
586
  newvode[1] = remember(state, newvode[1], void 0);
587
587
  }
588
588
  const properties = props(newVode);
589
- xmlns = properties?.xmlns || xmlns;
589
+ if (properties?.xmlns !== void 0) xmlns = properties.xmlns;
590
590
  const newNode = xmlns ? document.createElementNS(xmlns, newVode[0]) : document.createElement(newVode[0]);
591
591
  newVode.node = newNode;
592
- patchProperties(state, patch, newNode, void 0, properties);
592
+ patchProperties(state, newNode, void 0, properties, xmlns);
593
593
  if (!!properties && "catch" in properties) {
594
594
  newVode.node["catch"] = null;
595
595
  newVode.node.removeAttribute("catch");
596
596
  }
597
597
  if (oldNode) {
598
- oldNode.onUnmount && patch(oldNode.onUnmount(oldNode));
598
+ oldNode.onUnmount && state.patch(oldNode.onUnmount(oldNode));
599
599
  oldNode.replaceWith(newNode);
600
600
  } else {
601
601
  if (parent.childNodes[childIndex]) {
@@ -604,15 +604,16 @@ var V = (() => {
604
604
  parent.appendChild(newNode);
605
605
  }
606
606
  }
607
- const newChildren = children(newVode);
608
- if (newChildren) {
609
- for (let i = 0; i < newChildren.length; i++) {
610
- const child2 = newChildren[i];
611
- const attached = render(state, patch, newNode, i, void 0, child2, xmlns);
612
- newVode[properties ? i + 2 : i + 1] = attached;
607
+ const newKids = children(newVode);
608
+ if (newKids) {
609
+ const childOffset = !!properties ? 2 : 1;
610
+ for (let i = 0; i < newKids.length; i++) {
611
+ const child2 = newKids[i];
612
+ const attached = render(state, newNode, i, void 0, child2, xmlns);
613
+ newVode[i + childOffset] = attached;
613
614
  }
614
615
  }
615
- newNode.onMount && patch(newNode.onMount(newNode));
616
+ newNode.onMount && state.patch(newNode.onMount(newNode));
616
617
  return newVode;
617
618
  }
618
619
  if (!oldIsText && isNode && oldVode[0] === newVode[0]) {
@@ -620,16 +621,16 @@ var V = (() => {
620
621
  const newvode = newVode;
621
622
  const oldvode = oldVode;
622
623
  const properties = props(newVode);
623
- let hasProps = !!properties;
624
624
  const oldProps = props(oldVode);
625
+ if (properties?.xmlns !== void 0) xmlns = properties.xmlns;
625
626
  if (newvode[1]?.__memo) {
626
627
  const prev = newvode[1];
627
628
  newvode[1] = remember(state, newvode[1], oldvode[1]);
628
629
  if (prev !== newvode[1]) {
629
- patchProperties(state, patch, oldNode, oldProps, properties);
630
+ patchProperties(state, oldNode, oldProps, properties, xmlns);
630
631
  }
631
632
  } else {
632
- patchProperties(state, patch, oldNode, oldProps, properties);
633
+ patchProperties(state, oldNode, oldProps, properties, xmlns);
633
634
  }
634
635
  if (!!properties?.catch && oldProps?.catch !== properties.catch) {
635
636
  newVode.node["catch"] = null;
@@ -638,19 +639,20 @@ var V = (() => {
638
639
  const newKids = children(newVode);
639
640
  const oldKids = children(oldVode);
640
641
  if (newKids) {
642
+ const childOffset = !!properties ? 2 : 1;
641
643
  for (let i = 0; i < newKids.length; i++) {
642
644
  const child2 = newKids[i];
643
645
  const oldChild = oldKids && oldKids[i];
644
- const attached = render(state, patch, oldNode, i, oldChild, child2, xmlns);
646
+ const attached = render(state, oldNode, i, oldChild, child2, xmlns);
645
647
  if (attached) {
646
- newVode[hasProps ? i + 2 : i + 1] = attached;
648
+ newVode[i + childOffset] = attached;
647
649
  }
648
650
  }
649
651
  }
650
652
  if (oldKids) {
651
653
  const newKidsCount = newKids ? newKids.length : 0;
652
654
  for (let i = oldKids.length - 1; i >= newKidsCount; i--) {
653
- render(state, patch, oldNode, i, oldKids[i], void 0, xmlns);
655
+ render(state, oldNode, i, oldKids[i], void 0, xmlns);
654
656
  }
655
657
  }
656
658
  return newVode;
@@ -661,7 +663,6 @@ var V = (() => {
661
663
  const handledVode = typeof catchVode === "function" ? catchVode(state, error) : catchVode;
662
664
  return render(
663
665
  state,
664
- patch,
665
666
  parent,
666
667
  childIndex,
667
668
  hydrate(newVode?.node || oldVode?.node, true),
@@ -708,15 +709,18 @@ var V = (() => {
708
709
  return c;
709
710
  }
710
711
  }
711
- function patchProperties(s, patch, node, oldProps, newProps) {
712
+ function patchProperties(s, node, oldProps, newProps, xmlns) {
712
713
  if (!newProps && !oldProps) return;
714
+ const xmlMode = xmlns !== void 0;
713
715
  if (oldProps) {
714
716
  for (const key in oldProps) {
715
717
  const oldValue = oldProps[key];
716
718
  const newValue = newProps?.[key];
717
719
  if (oldValue !== newValue) {
718
- if (newProps) newProps[key] = patchProperty(s, patch, node, key, oldValue, newValue);
719
- else patchProperty(s, patch, node, key, oldValue, void 0);
720
+ if (newProps)
721
+ newProps[key] = patchProperty(s, node, key, oldValue, newValue, xmlMode);
722
+ else
723
+ patchProperty(s, node, key, oldValue, void 0, xmlMode);
720
724
  }
721
725
  }
722
726
  }
@@ -724,17 +728,17 @@ var V = (() => {
724
728
  for (const key in newProps) {
725
729
  if (!(key in oldProps)) {
726
730
  const newValue = newProps[key];
727
- newProps[key] = patchProperty(s, patch, node, key, void 0, newValue);
731
+ newProps[key] = patchProperty(s, node, key, void 0, newValue, xmlMode);
728
732
  }
729
733
  }
730
734
  } else if (newProps) {
731
735
  for (const key in newProps) {
732
736
  const newValue = newProps[key];
733
- newProps[key] = patchProperty(s, patch, node, key, void 0, newValue);
737
+ newProps[key] = patchProperty(s, node, key, void 0, newValue, xmlMode);
734
738
  }
735
739
  }
736
740
  }
737
- function patchProperty(s, patch, node, key, oldValue, newValue) {
741
+ function patchProperty(s, node, key, oldValue, newValue, xmlMode) {
738
742
  if (key === "style") {
739
743
  if (!newValue) {
740
744
  node.style.cssText = "";
@@ -770,16 +774,16 @@ var V = (() => {
770
774
  let eventHandler = null;
771
775
  if (typeof newValue === "function") {
772
776
  const action = newValue;
773
- eventHandler = (evt) => patch(action(s, evt));
777
+ eventHandler = (evt) => s.patch(action(s, evt));
774
778
  } else if (typeof newValue === "object") {
775
- eventHandler = () => patch(newValue);
779
+ eventHandler = () => s.patch(newValue);
776
780
  }
777
781
  node[key] = eventHandler;
778
782
  } else {
779
783
  node[key] = null;
780
784
  }
781
785
  } else {
782
- node[key] = newValue;
786
+ if (!xmlMode) node[key] = newValue;
783
787
  if (newValue === void 0 || newValue === null || newValue === false)
784
788
  node.removeAttribute(key);
785
789
  else
@@ -1052,6 +1056,26 @@ var V = (() => {
1052
1056
  return finalClass;
1053
1057
  }
1054
1058
 
1059
+ // src/merge-style.ts
1060
+ var tempDivForStyling = document.createElement("div");
1061
+ function mergeStyle(...props2) {
1062
+ try {
1063
+ const merged = tempDivForStyling.style;
1064
+ for (const style of props2) {
1065
+ if (typeof style === "object" && style !== null) {
1066
+ for (const key in style) {
1067
+ merged[key] = style[key];
1068
+ }
1069
+ } else if (typeof style === "string") {
1070
+ merged.cssText += ";" + style;
1071
+ }
1072
+ }
1073
+ return merged.cssText;
1074
+ } finally {
1075
+ tempDivForStyling.style.cssText = "";
1076
+ }
1077
+ }
1078
+
1055
1079
  // src/state-context.ts
1056
1080
  var KeyStateContext = class {
1057
1081
  constructor(state, path) {
package/dist/vode.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";var V=(()=>{var D=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var B=(e,n)=>{for(var a in n)D(e,a,{get:n[a],enumerable:!0})},_=(e,n,a,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of G(n))!K.call(e,t)&&t!==a&&D(e,t,{get:()=>n[t],enumerable:!(s=U(n,t))||s.enumerable});return e};var q=e=>_(D({},"__esModule",{value:!0}),e);var qn={};B(qn,{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:()=>At,DATALIST:()=>Pt,DD:()=>Ct,DEFS:()=>So,DEL:()=>Mt,DESC:()=>fo,DETAILS:()=>Nt,DFN:()=>Rt,DIALOG:()=>Ot,DIV:()=>Dt,DL:()=>vt,DT:()=>Lt,DelegateStateContext:()=>V,ELLIPSE:()=>uo,EM:()=>It,EMBED:()=>Vt,FEBLEND:()=>To,FECOLORMATRIX:()=>yo,FECOMPONENTTRANSFER:()=>go,FECOMPOSITE:()=>xo,FECONVOLVEMATRIX:()=>ho,FEDIFFUSELIGHTING:()=>mo,FEDISPLACEMENTMAP:()=>Eo,FEDISTANTLIGHT:()=>bo,FEDROPSHADOW:()=>Ao,FEFLOOD:()=>Po,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:()=>I,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:()=>An,MPADDED:()=>Pn,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:()=>Ae,Q:()=>Pe,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:()=>M,childrenStart:()=>O,createPatch:()=>J,createState:()=>W,defuse:()=>w,globals:()=>E,hydrate:()=>R,memo:()=>Y,mergeClass:()=>_n,props:()=>b,tag:()=>Q,vode:()=>X});var E={currentViewTransition:void 0,requestAnimationFrame:window.requestAnimationFrame?window.requestAnimationFrame.bind(window):(e=>e()),startViewTransition:document.startViewTransition?document.startViewTransition.bind(document):null};function X(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 $(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=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},Object.defineProperty(n,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async(c,d)=>{if(!(!c||typeof c!="function"&&typeof c!="object"))if(t.stats.patchCount++,c?.next){let S=c;t.stats.liveEffectCount++;try{let g=await S.next();for(;g.done===!1;){t.stats.liveEffectCount++;try{t.patch(g.value,d),g=await S.next()}finally{t.stats.liveEffectCount--}}t.patch(g.value,d)}finally{t.stats.liveEffectCount--}}else if(c.then){t.stats.liveEffectCount++;try{let S=await c;t.patch(S,d)}finally{t.stats.liveEffectCount--}}else if(Array.isArray(c))if(c.length>0)for(let S of c)t.patch(S,!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 c=="function"?t.patch(c(t.state),d):d?(t.stats.asyncRenderPatchCount++,t.qAsync=y(t.qAsync||{},c,!1),await t.renderAsync()):(t.stats.syncRenderPatchCount++,t.qSync=y(t.qSync||{},c,!1),t.renderSync())}});function o(c){let d=Date.now(),S=a(t.state);t.vode=P(t.state,t.patch,e.parentElement,0,t.vode,S),e.tagName.toUpperCase()!==S[0].toUpperCase()&&(e=t.vode.node,e._vode=t),c||(t.stats.lastSyncRenderTime=Date.now()-d,t.stats.syncRenderCount++,t.isRendering=!1,t.qSync&&t.renderSync())}let r=o.bind(null,!1),i=o.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(r))}}),Object.defineProperty(t,"renderAsync",{enumerable:!1,configurable:!0,writable:!1,value:async()=>{if(t.isAnimating||!t.qAsync||(await E.currentViewTransition?.updateCallbackDone,t.isAnimating||!t.qAsync||document.hidden))return;t.isAnimating=!0;let c=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()-c,t.stats.asyncRenderCount++,t.isAnimating=!1}t.qAsync&&t.renderAsync()}}),t.patch=n.patch,t.state=n;let p=e;p._vode=t,t.vode=P(n,t.patch,e.parentElement,Array.from(e.parentElement.children).indexOf(e),R(e,!0),a(n));for(let c of s)t.patch(c);return t.patch}function w(e){if(e?._vode){let a=function(t){if(!t?.node)return;let o=b(t);if(o){for(let i in o)i[0]==="o"&&i[1]==="n"&&(t.node[i]=null);t.node.catch=null}let r=M(t);if(r)for(let i of r)a(i)};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 Y(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 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 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=O(e);return n>0?e.slice(n):null}function z(e){let n=O(e);return n<0?0:e.length-n}function Z(e,n){let a=O(e);if(a>0)return e[n+a]}function O(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 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]=y({},t,a):typeof o=="object"?y(e[s],t,a):e[s]=y({},t,a):Array.isArray(t)?e[s]=[...t]:t instanceof Date?e[s]=new Date(t):e[s]=y({},t,a)}else t===void 0&&a?delete e[s]:e[s]=t}return e}function P(e,n,a,s,t,o,r){try{o=v(e,o,t);let i=!o||typeof o=="number"||typeof o=="boolean";if(o===t||!t&&i)return t;let p=t?.nodeType===Node.TEXT_NODE,c=p?t:t?.node;if(i){c?.onUnmount&&n(c.onUnmount(c)),c?.remove();return}let d=!i&&et(o),S=!i&&tt(o),g=!!o&&typeof o!="string"&&!!(o?.node||o?.nodeType===Node.TEXT_NODE);if(!d&&!S&&!g&&!t)throw new Error("Invalid vode: "+typeof o+" "+JSON.stringify(o));if(g&&d?o=o.wholeText:g&&S&&(o=[...o]),p&&d)return c.nodeValue!==o&&(c.nodeValue=o),t;if(d&&(!c||!p)){let f=document.createTextNode(o);return c?(c.onUnmount&&n(c.onUnmount(c)),c.replaceWith(f)):a.childNodes[s]?a.insertBefore(f,a.childNodes[s]):a.appendChild(f),f}if(S&&(!c||p||t[0]!==o[0])){let f=o;1 in f&&(f[1]=v(e,f[1],void 0));let x=b(o);r=x?.xmlns||r;let l=r?document.createElementNS(r,o[0]):document.createElement(o[0]);o.node=l,L(e,n,l,void 0,x),x&&"catch"in x&&(o.node.catch=null,o.node.removeAttribute("catch")),c?(c.onUnmount&&n(c.onUnmount(c)),c.replaceWith(l)):a.childNodes[s]?a.insertBefore(l,a.childNodes[s]):a.appendChild(l);let C=M(o);if(C)for(let T=0;T<C.length;T++){let h=C[T],m=P(e,n,l,T,void 0,h,r);o[x?T+2:T+1]=m}return l.onMount&&n(l.onMount(l)),o}if(!p&&S&&t[0]===o[0]){o.node=c;let f=o,x=t,l=b(o),C=!!l,T=b(t);if(f[1]?.__memo){let u=f[1];f[1]=v(e,f[1],x[1]),u!==f[1]&&L(e,n,c,T,l)}else L(e,n,c,T,l);l?.catch&&T?.catch!==l.catch&&(o.node.catch=null,o.node.removeAttribute("catch"));let h=M(o),m=M(t);if(h)for(let u=0;u<h.length;u++){let A=h[u],H=m&&m[u],F=P(e,n,c,u,H,A,r);F&&(o[C?u+2:u+1]=F)}if(m){let u=h?h.length:0;for(let A=m.length-1;A>=u;A--)P(e,n,c,A,m[A],void 0,r)}return o}}catch(i){let p=b(o)?.catch;if(p){let c=typeof p=="function"?p(e,i):p;return P(e,n,a,s,R(o?.node||t?.node,!0),c,r)}else throw i}}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 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 i=0;i<s.length;i++)if(s[i]!==t[i]){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(!(!t&&!s)){if(s)for(let o in s){let r=s[o],i=t?.[o];r!==i&&(t?t[o]=N(e,n,a,o,r,i):N(e,n,a,o,r,void 0))}if(t&&s){for(let o in t)if(!(o in s)){let r=t[o];t[o]=N(e,n,a,o,void 0,r)}}else if(t)for(let o in t){let r=t[o];t[o]=N(e,n,a,o,void 0,r)}}}function N(e,n,a,s,t,o){if(s==="style")if(!o)a.style.cssText="";else if(typeof o=="string")t!==o&&(a.style.cssText=o);else if(t&&typeof t=="object"){for(let r in t)o[r]||(a.style[r]=null);for(let r in o){let i=t[r],p=o[r];i!==p&&(a.style[r]=p)}}else for(let r in o)a.style[r]=o[r];else if(s==="class")o?a.setAttribute("class",j(o)):a.removeAttribute("class");else if(s[0]==="o"&&s[1]==="n")if(o){let r=null;if(typeof o=="function"){let i=o;r=p=>n(i(e,p))}else typeof o=="object"&&(r=()=>n(o));a[s]=r}else a[s]=null;else a[s]=o,o==null||o===!1?a.removeAttribute(s):a.setAttribute(s,o);return o}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 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",At="data",Pt="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",Ae="progress",Pe="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",Ao="feDropShadow",Po="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",An="mover",Pn="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 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(" "),i=new Set([...o,...r]);n=Array.from(i).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 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 q(qn);})();
1
+ "use strict";var V=(()=>{var R=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var B=(e,n)=>{for(var s in n)R(e,s,{get:n[s],enumerable:!0})},_=(e,n,s,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of G(n))!K.call(e,t)&&t!==s&&R(e,t,{get:()=>n[t],enumerable:!(o=U(n,t))||o.enumerable});return e};var q=e=>_(R({},"__esModule",{value:!0}),e);var Xo={};B(Xo,{A:()=>nt,ABBR:()=>ot,ADDRESS:()=>st,ANIMATE:()=>rn,ANIMATEMOTION:()=>cn,ANIMATETRANSFORM:()=>pn,ANNOTATION:()=>So,ANNOTATION_XML:()=>uo,AREA:()=>at,ARTICLE:()=>rt,ASIDE:()=>ct,AUDIO:()=>it,B:()=>pt,BASE:()=>lt,BDI:()=>ft,BDO:()=>St,BLOCKQUOTE:()=>dt,BODY:()=>ut,BR:()=>Tt,BUTTON:()=>yt,CANVAS:()=>gt,CAPTION:()=>xt,CIRCLE:()=>ln,CITE:()=>ht,CLIPPATH:()=>fn,CODE:()=>mt,COL:()=>Et,COLGROUP:()=>bt,DATA:()=>Pt,DATALIST:()=>At,DD:()=>Ct,DEFS:()=>Sn,DEL:()=>Mt,DESC:()=>dn,DETAILS:()=>Nt,DFN:()=>Rt,DIALOG:()=>Ot,DIV:()=>Dt,DL:()=>vt,DT:()=>Lt,DelegateStateContext:()=>L,ELLIPSE:()=>un,EM:()=>It,EMBED:()=>Vt,FEBLEND:()=>Tn,FECOLORMATRIX:()=>yn,FECOMPONENTTRANSFER:()=>gn,FECOMPOSITE:()=>xn,FECONVOLVEMATRIX:()=>hn,FEDIFFUSELIGHTING:()=>mn,FEDISPLACEMENTMAP:()=>En,FEDISTANTLIGHT:()=>bn,FEDROPSHADOW:()=>Pn,FEFLOOD:()=>An,FEFUNCA:()=>Cn,FEFUNCB:()=>Mn,FEFUNCG:()=>Nn,FEFUNCR:()=>Rn,FEGAUSSIANBLUR:()=>On,FEIMAGE:()=>Dn,FEMERGE:()=>vn,FEMERGENODE:()=>Ln,FEMORPHOLOGY:()=>In,FEOFFSET:()=>Vn,FEPOINTLIGHT:()=>Fn,FESPECULARLIGHTING:()=>kn,FESPOTLIGHT:()=>jn,FETILE:()=>Hn,FETURBULENCE:()=>Un,FIELDSET:()=>Ft,FIGCAPTION:()=>kt,FIGURE:()=>jt,FILTER:()=>Gn,FOOTER:()=>Ht,FOREIGNOBJECT:()=>Kn,FORM:()=>Ut,G:()=>Bn,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:()=>_n,IMG:()=>Zt,INPUT:()=>te,INS:()=>ee,KBD:()=>ne,KeyStateContext:()=>v,LABEL:()=>oe,LEGEND:()=>se,LI:()=>ae,LINE:()=>qn,LINEARGRADIENT:()=>Xn,LINK:()=>re,MACTION:()=>To,MAIN:()=>ce,MAP:()=>ie,MARK:()=>pe,MARKER:()=>$n,MASK:()=>wn,MATH:()=>yo,MENU:()=>le,MERROR:()=>go,META:()=>fe,METADATA:()=>Yn,METER:()=>Se,MFRAC:()=>xo,MI:()=>ho,MMULTISCRIPTS:()=>mo,MN:()=>Eo,MO:()=>bo,MOVER:()=>Po,MPADDED:()=>Ao,MPATH:()=>Wn,MPHANTOM:()=>Co,MPRESCRIPTS:()=>Mo,MROOT:()=>No,MROW:()=>Ro,MS:()=>Oo,MSPACE:()=>Do,MSQRT:()=>vo,MSTYLE:()=>Lo,MSUB:()=>Io,MSUBSUP:()=>Vo,MSUP:()=>Fo,MTABLE:()=>ko,MTD:()=>jo,MTEXT:()=>Ho,MTR:()=>Uo,MUNDER:()=>Go,MUNDEROVER:()=>Ko,NAV:()=>de,NOSCRIPT:()=>ue,OBJECT:()=>Te,OL:()=>ye,OPTGROUP:()=>ge,OPTION:()=>xe,OUTPUT:()=>he,P:()=>me,PATH:()=>Jn,PATTERN:()=>Qn,PICTURE:()=>Ee,POLYGON:()=>zn,POLYLINE:()=>Zn,PRE:()=>be,PROGRESS:()=>Pe,Q:()=>Ae,RADIALGRADIENT:()=>to,RECT:()=>eo,RP:()=>Ce,RT:()=>Me,RUBY:()=>Ne,S:()=>Re,SAMP:()=>Oe,SCRIPT:()=>De,SEARCH:()=>ve,SECTION:()=>Le,SELECT:()=>Ie,SEMANTICS:()=>Bo,SET:()=>no,SLOT:()=>Ve,SMALL:()=>Fe,SOURCE:()=>ke,SPAN:()=>je,STOP:()=>oo,STRONG:()=>He,STYLE:()=>Ue,SUB:()=>Ge,SUMMARY:()=>Ke,SUP:()=>Be,SVG:()=>so,SWITCH:()=>ao,SYMBOL:()=>ro,TABLE:()=>_e,TBODY:()=>qe,TD:()=>Xe,TEMPLATE:()=>$e,TEXT:()=>co,TEXTAREA:()=>we,TEXTPATH:()=>io,TFOOT:()=>Ye,TH:()=>We,THEAD:()=>Je,TIME:()=>Qe,TITLE:()=>ze,TR:()=>Ze,TRACK:()=>tn,TSPAN:()=>po,U:()=>en,UL:()=>nn,USE:()=>lo,VAR:()=>on,VIDEO:()=>sn,VIEW:()=>fo,WBR:()=>an,app:()=>$,child:()=>Z,childCount:()=>z,children:()=>A,childrenStart:()=>N,createPatch:()=>J,createState:()=>W,defuse:()=>w,globals:()=>m,hydrate:()=>M,memo:()=>Y,mergeClass:()=>_o,mergeStyle:()=>qo,props:()=>E,tag:()=>Q,vode:()=>X});var m={currentViewTransition:void 0,requestAnimationFrame:window.requestAnimationFrame?window.requestAnimationFrame.bind(window):(e=>e()),startViewTransition:document.startViewTransition?document.startViewTransition.bind(document):null};function X(e,n,...s){if(!e)throw new Error("first argument to vode() must be a tag name or a vode");return Array.isArray(e)?e:n?[e,n,...s]:[e,...s]}function $(e,n,s,...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 s!="function")throw new Error("third argument to app() must be a function that returns a vode");let t={};t.syncRenderer=m.requestAnimationFrame,t.asyncRenderer=m.startViewTransition,t.qSync=null,t.qAsync=null,t.stats={lastSyncRenderTime:0,lastAsyncRenderTime:0,syncRenderCount:0,asyncRenderCount:0,liveEffectCount:0,patchCount:0,syncRenderPatchCount:0,asyncRenderPatchCount:0};let a=n;Object.defineProperty(n,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async(p,u)=>{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{a.patch(S.value,u),S=await l.next()}finally{t.stats.liveEffectCount--}}a.patch(S.value,u)}finally{t.stats.liveEffectCount--}}else if(p.then){t.stats.liveEffectCount++;try{let l=await p;a.patch(l,u)}finally{t.stats.liveEffectCount--}}else if(Array.isArray(p))if(p.length>0)for(let l of p)a.patch(l,!document.hidden&&!!t.asyncRenderer);else{t.qSync=y(t.qSync||{},t.qAsync,!1),t.qAsync=null;try{m.currentViewTransition?.skipTransition()}catch{}t.stats.syncRenderPatchCount++,t.renderSync()}else typeof p=="function"?a.patch(p(t.state),u):u?(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 u=Date.now(),l=s(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()-u,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 m.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,m.currentViewTransition=t.asyncRenderer(i),await m.currentViewTransition?.updateCallbackDone}finally{t.stats.lastAsyncRenderTime=Date.now()-p,t.stats.asyncRenderCount++,t.isAnimating=!1}t.qAsync&&t.renderAsync()}}),t.state=a;let b=e;b._vode=t,t.vode=P(n,e.parentElement,Array.from(e.parentElement.children).indexOf(e),M(e,!0),s(n));for(let p of o)a.patch(p);return p=>a.patch(p)}function w(e){if(e?._vode){let s=function(t){if(!t?.node)return;let a=E(t);if(a){for(let c in a)c[0]==="o"&&c[1]==="n"&&(t.node[c]=null);t.node.catch=null}let r=A(t);if(r)for(let c of r)s(c)};var n=s;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:()=>{}}),s(o.vode)}}function M(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={},a=e.attributes;for(let r of a)t[r.name]=r.value;o.push(t)}if(e.hasChildNodes()){let t=[];for(let a of e.childNodes){let r=a&&M(a,n);r?o.push(r):a&&n&&t.push(a)}for(let a of t)a.remove()}return o}else return}function Y(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 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 E(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 A(e){let n=N(e);return n>0?e.slice(n):null}function z(e){let n=N(e);return n<0?0:e.length-n}function Z(e,n){let s=N(e);if(s>0)return e[n+s]}function N(e){return E(e)?e.length>2?2:-1:Array.isArray(e)&&e.length>1?1:-1}function y(e,n,s){if(!n)return e;for(let o in n){let t=n[o];if(t&&typeof t=="object"){let a=e[o];a?Array.isArray(t)?e[o]=[...t]:t instanceof Date&&a!==t?e[o]=new Date(t):Array.isArray(a)?e[o]=y({},t,s):typeof a=="object"?y(e[o],t,s):e[o]=y({},t,s):Array.isArray(t)?e[o]=[...t]:t instanceof Date?e[o]=new Date(t):e[o]=y({},t,s)}else t===void 0&&s?delete e[o]:e[o]=t}return e}function P(e,n,s,o,t,a){try{t=O(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 b=!r&&et(t),p=!r&&tt(t),u=!!t&&typeof t!="string"&&!!(t?.node||t?.nodeType===Node.TEXT_NODE);if(!b&&!p&&!u&&!o)throw new Error("Invalid vode: "+typeof t+" "+JSON.stringify(t));if(u&&b?t=t.wholeText:u&&p&&(t=[...t]),c&&b)return i.nodeValue!==t&&(i.nodeValue=t),o;if(b&&(!i||!c)){let l=document.createTextNode(t);return i?(i.onUnmount&&e.patch(i.onUnmount(i)),i.replaceWith(l)):n.childNodes[s]?n.insertBefore(l,n.childNodes[s]):n.appendChild(l),l}if(p&&(!i||c||o[0]!==t[0])){let l=t;1 in l&&(l[1]=O(e,l[1],void 0));let S=E(t);S?.xmlns!==void 0&&(a=S.xmlns);let f=a?document.createElementNS(a,t[0]):document.createElement(t[0]);t.node=f,D(e,f,void 0,S,a),S&&"catch"in S&&(t.node.catch=null,t.node.removeAttribute("catch")),i?(i.onUnmount&&e.patch(i.onUnmount(i)),i.replaceWith(f)):n.childNodes[s]?n.insertBefore(f,n.childNodes[s]):n.appendChild(f);let g=A(t);if(g){let x=S?2:1;for(let T=0;T<g.length;T++){let h=g[T],d=P(e,f,T,void 0,h,a);t[T+x]=d}}return f.onMount&&e.patch(f.onMount(f)),t}if(!c&&p&&o[0]===t[0]){t.node=i;let l=t,S=o,f=E(t),g=E(o);if(f?.xmlns!==void 0&&(a=f.xmlns),l[1]?.__memo){let h=l[1];l[1]=O(e,l[1],S[1]),h!==l[1]&&D(e,i,g,f,a)}else D(e,i,g,f,a);f?.catch&&g?.catch!==f.catch&&(t.node.catch=null,t.node.removeAttribute("catch"));let x=A(t),T=A(o);if(x){let h=f?2:1;for(let d=0;d<x.length;d++){let j=x[d],H=T&&T[d],I=P(e,i,d,H,j,a);I&&(t[d+h]=I)}}if(T){let h=x?x.length:0;for(let d=T.length-1;d>=h;d--)P(e,i,d,T[d],void 0,a)}return t}}catch(r){let c=E(t)?.catch;if(c){let i=typeof c=="function"?c(e,r):c;return P(e,n,s,M(t?.node||o?.node,!0),i,a)}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 O(e,n,s){if(typeof n!="function")return n;let o=n?.__memo,t=s?.__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 s}let a=V(n,e);return typeof a=="object"&&(a.__memo=n?.__memo),a}function V(e,n){return typeof e=="function"?V(e(n),n):e}function D(e,n,s,o,t){if(!o&&!s)return;let a=t!==void 0;if(s)for(let r in s){let c=s[r],i=o?.[r];c!==i&&(o?o[r]=C(e,n,r,c,i,a):C(e,n,r,c,void 0,a))}if(o&&s){for(let r in o)if(!(r in s)){let c=o[r];o[r]=C(e,n,r,void 0,c,a)}}else if(o)for(let r in o){let c=o[r];o[r]=C(e,n,r,void 0,c,a)}}function C(e,n,s,o,t,a){if(s==="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 r in o)t[r]||(n.style[r]=null);for(let r in t){let c=o[r],i=t[r];c!==i&&(n.style[r]=i)}}else for(let r in t)n.style[r]=t[r];else if(s==="class")t?n.setAttribute("class",F(t)):n.removeAttribute("class");else if(s[0]==="o"&&s[1]==="n")if(t){let r=null;if(typeof t=="function"){let c=t;r=i=>e.patch(c(e,i))}else typeof t=="object"&&(r=()=>e.patch(t));n[s]=r}else n[s]=null;else a||(n[s]=t),t==null||t===!1?n.removeAttribute(s):n.setAttribute(s,t);return t}function F(e){return typeof e=="string"?e:Array.isArray(e)?e.map(F).join(" "):typeof e=="object"?Object.keys(e).filter(n=>e[n]).join(" "):""}var nt="a",ot="abbr",st="address",at="area",rt="article",ct="aside",it="audio",pt="b",lt="base",ft="bdi",St="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",ne="kbd",oe="label",se="legend",ae="li",re="link",ce="main",ie="map",pe="mark",le="menu",fe="meta",Se="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",tn="track",en="u",nn="ul",on="var",sn="video",an="wbr",rn="animate",cn="animateMotion",pn="animateTransform",ln="circle",fn="clipPath",Sn="defs",dn="desc",un="ellipse",Tn="feBlend",yn="feColorMatrix",gn="feComponentTransfer",xn="feComposite",hn="feConvolveMatrix",mn="feDiffuseLighting",En="feDisplacementMap",bn="feDistantLight",Pn="feDropShadow",An="feFlood",Cn="feFuncA",Mn="feFuncB",Nn="feFuncG",Rn="feFuncR",On="feGaussianBlur",Dn="feImage",vn="feMerge",Ln="feMergeNode",In="feMorphology",Vn="feOffset",Fn="fePointLight",kn="feSpecularLighting",jn="feSpotLight",Hn="feTile",Un="feTurbulence",Gn="filter",Kn="foreignObject",Bn="g",_n="image",qn="line",Xn="linearGradient",$n="marker",wn="mask",Yn="metadata",Wn="mpath",Jn="path",Qn="pattern",zn="polygon",Zn="polyline",to="radialGradient",eo="rect",no="set",oo="stop",so="svg",ao="switch",ro="symbol",co="text",io="textPath",po="tspan",lo="use",fo="view",So="annotation",uo="annotation-xml",To="maction",yo="math",go="merror",xo="mfrac",ho="mi",mo="mmultiscripts",Eo="mn",bo="mo",Po="mover",Ao="mpadded",Co="mphantom",Mo="mprescripts",No="mroot",Ro="mrow",Oo="ms",Do="mspace",vo="msqrt",Lo="mstyle",Io="msub",Vo="msubsup",Fo="msup",ko="mtable",jo="mtd",Ho="mtext",Uo="mtr",Go="munder",Ko="munderover",Bo="semantics";function _o(...e){if(!e||e.length===0)return null;if(e.length===1)return e[0];let n=e[0];for(let s=1;s<e.length;s++){let o=n,t=e[s];if(!o)n=t;else if(t)if(typeof o=="string"&&typeof t=="string"){let a=o.split(" "),r=t.split(" "),c=new Set([...a,...r]);n=Array.from(c).join(" ").trim()}else if(typeof o=="string"&&Array.isArray(t)){let a=new Set([...t,...o.split(" ")]);n=Array.from(a).join(" ").trim()}else if(Array.isArray(o)&&typeof t=="string"){let a=new Set([...o,...t.split(" ")]);n=Array.from(a).join(" ").trim()}else if(Array.isArray(o)&&Array.isArray(t)){let a=new Set([...o,...t]);n=Array.from(a).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 a={...o};for(let r of t)a[r]=!0;n=a}else if(Array.isArray(o)&&typeof t=="object"){let a={};for(let r of o)a[r]=!0;for(let r of Object.keys(t))a[r]=t[r];n=a}else throw new Error(`cannot merge classes of ${o} (${typeof o}) and ${t} (${typeof t})`);else continue}return n}var k=document.createElement("div");function qo(...e){try{let n=k.style;for(let s of e)if(typeof s=="object"&&s!==null)for(let o in s)n[o]=s[o];else typeof s=="string"&&(n.cssText+=";"+s);return n.cssText}finally{k.style.cssText=""}}var v=class{constructor(n,s){this.state=n;this.path=s;this.keys=s.split(".")}keys;get(){let n=this.keys,s=this.state?this.state[n[0]]:void 0;for(let o=1;o<n.length&&s;o++)s=s[n[o]];return s}put(n){this.putDeep(n,this.state)}patch(n){if(Array.isArray(n)){let s=[];for(let o of n)s.push(this.createPatch(o));this.state.patch(s)}else this.state.patch(this.createPatch(n))}createPatch(n){let s={};return this.putDeep(n,s),s}putDeep(n,s){let o=this.keys;if(o.length>1){let t=0,a=s[o[t]];for((typeof a!="object"||a===null)&&(s[o[t]]=a={}),t=1;t<o.length-1;t++){let r=a;a=a[o[t]],(typeof a!="object"||a===null)&&(r[o[t]]=a={})}a[o[t]]=n}else typeof s[o[0]]=="object"&&typeof n=="object"?Object.assign(s[o[0]],n):s[o[0]]=n}},L=class{constructor(n,s,o,t){this.state=n;this.get=s;this.put=o;this.patch=t}};return q(Xo);})();
package/dist/vode.min.mjs CHANGED
@@ -1 +1 @@
1
- var b={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,...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=b.requestAnimationFrame,t.asyncRenderer=b.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},Object.defineProperty(n,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async(c,d)=>{if(!(!c||typeof c!="function"&&typeof c!="object"))if(t.stats.patchCount++,c?.next){let S=c;t.stats.liveEffectCount++;try{let g=await S.next();for(;g.done===!1;){t.stats.liveEffectCount++;try{t.patch(g.value,d),g=await S.next()}finally{t.stats.liveEffectCount--}}t.patch(g.value,d)}finally{t.stats.liveEffectCount--}}else if(c.then){t.stats.liveEffectCount++;try{let S=await c;t.patch(S,d)}finally{t.stats.liveEffectCount--}}else if(Array.isArray(c))if(c.length>0)for(let S of c)t.patch(S,!document.hidden&&!!t.asyncRenderer);else{t.qSync=y(t.qSync||{},t.qAsync,!1),t.qAsync=null;try{b.currentViewTransition?.skipTransition()}catch{}t.stats.syncRenderPatchCount++,t.renderSync()}else typeof c=="function"?t.patch(c(t.state),d):d?(t.stats.asyncRenderPatchCount++,t.qAsync=y(t.qAsync||{},c,!1),await t.renderAsync()):(t.stats.syncRenderPatchCount++,t.qSync=y(t.qSync||{},c,!1),t.renderSync())}});function o(c){let d=Date.now(),S=a(t.state);t.vode=P(t.state,t.patch,e.parentElement,0,t.vode,S),e.tagName.toUpperCase()!==S[0].toUpperCase()&&(e=t.vode.node,e._vode=t),c||(t.stats.lastSyncRenderTime=Date.now()-d,t.stats.syncRenderCount++,t.isRendering=!1,t.qSync&&t.renderSync())}let r=o.bind(null,!1),i=o.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(r))}}),Object.defineProperty(t,"renderAsync",{enumerable:!1,configurable:!0,writable:!1,value:async()=>{if(t.isAnimating||!t.qAsync||(await b.currentViewTransition?.updateCallbackDone,t.isAnimating||!t.qAsync||document.hidden))return;t.isAnimating=!0;let c=Date.now();try{t.state=y(t.state,t.qAsync,!0),t.qAsync=null,b.currentViewTransition=t.asyncRenderer(i),await b.currentViewTransition?.updateCallbackDone}finally{t.stats.lastAsyncRenderTime=Date.now()-c,t.stats.asyncRenderCount++,t.isAnimating=!1}t.qAsync&&t.renderAsync()}}),t.patch=n.patch,t.state=n;let p=e;p._vode=t,t.vode=P(n,t.patch,e.parentElement,Array.from(e.parentElement.children).indexOf(e),D(e,!0),a(n));for(let c of s)t.patch(c);return t.patch}function B(e){if(e?._vode){let a=function(t){if(!t?.node)return;let o=A(t);if(o){for(let i in o)i[0]==="o"&&i[1]==="n"&&(t.node[i]=null);t.node.catch=null}let r=N(t);if(r)for(let i of r)a(i)};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 D(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&&D(o,n);r?s.push(r):o&&n&&t.push(o)}for(let o of t)o.remove()}return s}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 A(e){if(Array.isArray(e)&&e.length>1&&e[1]&&!Array.isArray(e[1])&&typeof e[1]=="object"&&e[1].nodeType!==Node.TEXT_NODE)return e[1]}function N(e){let n=v(e);return n>0?e.slice(n):null}function w(e){let n=v(e);return n<0?0:e.length-n}function Y(e,n){let a=v(e);if(a>0)return e[n+a]}function v(e){return A(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 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]=y({},t,a):typeof o=="object"?y(e[s],t,a):e[s]=y({},t,a):Array.isArray(t)?e[s]=[...t]:t instanceof Date?e[s]=new Date(t):e[s]=y({},t,a)}else t===void 0&&a?delete e[s]:e[s]=t}return e}function P(e,n,a,s,t,o,r){try{o=R(e,o,t);let i=!o||typeof o=="number"||typeof o=="boolean";if(o===t||!t&&i)return t;let p=t?.nodeType===Node.TEXT_NODE,c=p?t:t?.node;if(i){c?.onUnmount&&n(c.onUnmount(c)),c?.remove();return}let d=!i&&U(o),S=!i&&H(o),g=!!o&&typeof o!="string"&&!!(o?.node||o?.nodeType===Node.TEXT_NODE);if(!d&&!S&&!g&&!t)throw new Error("Invalid vode: "+typeof o+" "+JSON.stringify(o));if(g&&d?o=o.wholeText:g&&S&&(o=[...o]),p&&d)return c.nodeValue!==o&&(c.nodeValue=o),t;if(d&&(!c||!p)){let f=document.createTextNode(o);return c?(c.onUnmount&&n(c.onUnmount(c)),c.replaceWith(f)):a.childNodes[s]?a.insertBefore(f,a.childNodes[s]):a.appendChild(f),f}if(S&&(!c||p||t[0]!==o[0])){let f=o;1 in f&&(f[1]=R(e,f[1],void 0));let x=A(o);r=x?.xmlns||r;let l=r?document.createElementNS(r,o[0]):document.createElement(o[0]);o.node=l,O(e,n,l,void 0,x),x&&"catch"in x&&(o.node.catch=null,o.node.removeAttribute("catch")),c?(c.onUnmount&&n(c.onUnmount(c)),c.replaceWith(l)):a.childNodes[s]?a.insertBefore(l,a.childNodes[s]):a.appendChild(l);let C=N(o);if(C)for(let T=0;T<C.length;T++){let h=C[T],m=P(e,n,l,T,void 0,h,r);o[x?T+2:T+1]=m}return l.onMount&&n(l.onMount(l)),o}if(!p&&S&&t[0]===o[0]){o.node=c;let f=o,x=t,l=A(o),C=!!l,T=A(t);if(f[1]?.__memo){let u=f[1];f[1]=R(e,f[1],x[1]),u!==f[1]&&O(e,n,c,T,l)}else O(e,n,c,T,l);l?.catch&&T?.catch!==l.catch&&(o.node.catch=null,o.node.removeAttribute("catch"));let h=N(o),m=N(t);if(h)for(let u=0;u<h.length;u++){let E=h[u],j=m&&m[u],L=P(e,n,c,u,j,E,r);L&&(o[C?u+2:u+1]=L)}if(m){let u=h?h.length:0;for(let E=m.length-1;E>=u;E--)P(e,n,c,E,m[E],void 0,r)}return o}}catch(i){let p=A(o)?.catch;if(p){let c=typeof p=="function"?p(e,i):p;return P(e,n,a,s,D(o?.node||t?.node,!0),c,r)}else throw i}}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 R(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 i=0;i<s.length;i++)if(s[i]!==t[i]){r=!1;break}if(r)return a}let o=I(n,e);return typeof o=="object"&&(o.__memo=n?.__memo),o}function I(e,n){return typeof e=="function"?I(e(n),n):e}function O(e,n,a,s,t){if(!(!t&&!s)){if(s)for(let o in s){let r=s[o],i=t?.[o];r!==i&&(t?t[o]=M(e,n,a,o,r,i):M(e,n,a,o,r,void 0))}if(t&&s){for(let o in t)if(!(o in s)){let r=t[o];t[o]=M(e,n,a,o,void 0,r)}}else if(t)for(let o in t){let r=t[o];t[o]=M(e,n,a,o,void 0,r)}}}function M(e,n,a,s,t,o){if(s==="style")if(!o)a.style.cssText="";else if(typeof o=="string")t!==o&&(a.style.cssText=o);else if(t&&typeof t=="object"){for(let r in t)o[r]||(a.style[r]=null);for(let r in o){let i=t[r],p=o[r];i!==p&&(a.style[r]=p)}}else for(let r in o)a.style[r]=o[r];else if(s==="class")o?a.setAttribute("class",V(o)):a.removeAttribute("class");else if(s[0]==="o"&&s[1]==="n")if(o){let r=null;if(typeof o=="function"){let i=o;r=p=>n(i(e,p))}else typeof o=="object"&&(r=()=>n(o));a[s]=r}else a[s]=null;else a[s]=o,o==null||o===!1?a.removeAttribute(s):a.setAttribute(s,o);return o}function V(e){return typeof e=="string"?e:Array.isArray(e)?e.map(V).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",At="dialog",Pt="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",Ae="samp",Pe="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",Ao="feGaussianBlur",Po="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",An="ms",Pn="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 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(" "),i=new Set([...o,...r]);n=Array.from(i).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 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 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}},k=class{constructor(n,a,s,t){this.state=n;this.get=a;this.put=s;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,At as DIALOG,Pt 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,Ao as FEGAUSSIANBLUR,Po 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,An as MS,Pn 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,Ae as SAMP,Pe 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,N as children,v as childrenStart,X as createPatch,q as createState,B as defuse,b as globals,D as hydrate,_ as memo,Hn as mergeClass,A as props,$ as tag,G as vode};
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,o,...s){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,...s]:[e,...s]}function K(e,o,s,...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 s!="function")throw new Error("third argument to app() must be a function that returns a vode");let t={};t.syncRenderer=E.requestAnimationFrame,t.asyncRenderer=E.startViewTransition,t.qSync=null,t.qAsync=null,t.stats={lastSyncRenderTime:0,lastAsyncRenderTime:0,syncRenderCount:0,asyncRenderCount:0,liveEffectCount:0,patchCount:0,syncRenderPatchCount:0,asyncRenderPatchCount:0};let a=o;Object.defineProperty(o,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async(p,u)=>{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{a.patch(S.value,u),S=await l.next()}finally{t.stats.liveEffectCount--}}a.patch(S.value,u)}finally{t.stats.liveEffectCount--}}else if(p.then){t.stats.liveEffectCount++;try{let l=await p;a.patch(l,u)}finally{t.stats.liveEffectCount--}}else if(Array.isArray(p))if(p.length>0)for(let l of p)a.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"?a.patch(p(t.state),u):u?(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 u=Date.now(),l=s(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()-u,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=a;let m=e;m._vode=t,t.vode=P(o,e.parentElement,Array.from(e.parentElement.children).indexOf(e),R(e,!0),s(o));for(let p of n)a.patch(p);return p=>a.patch(p)}function B(e){if(e?._vode){let s=function(t){if(!t?.node)return;let a=b(t);if(a){for(let c in a)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)s(c)};var o=s;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:()=>{}}),s(n.vode)}}function R(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={},a=e.attributes;for(let r of a)t[r.name]=r.value;n.push(t)}if(e.hasChildNodes()){let t=[];for(let a of e.childNodes){let r=a&&R(a,o);r?n.push(r):a&&o&&t.push(a)}for(let a of t)a.remove()}return n}else return}function _(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 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 C(e){let o=O(e);return o>0?e.slice(o):null}function w(e){let o=O(e);return o<0?0:e.length-o}function Y(e,o){let s=O(e);if(s>0)return e[o+s]}function O(e){return b(e)?e.length>2?2:-1:Array.isArray(e)&&e.length>1?1:-1}function y(e,o,s){if(!o)return e;for(let n in o){let t=o[n];if(t&&typeof t=="object"){let a=e[n];a?Array.isArray(t)?e[n]=[...t]:t instanceof Date&&a!==t?e[n]=new Date(t):Array.isArray(a)?e[n]=y({},t,s):typeof a=="object"?y(e[n],t,s):e[n]=y({},t,s):Array.isArray(t)?e[n]=[...t]:t instanceof Date?e[n]=new Date(t):e[n]=y({},t,s)}else t===void 0&&s?delete e[n]:e[n]=t}return e}function P(e,o,s,n,t,a){try{t=M(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 m=!r&&U(t),p=!r&&H(t),u=!!t&&typeof t!="string"&&!!(t?.node||t?.nodeType===Node.TEXT_NODE);if(!m&&!p&&!u&&!n)throw new Error("Invalid vode: "+typeof t+" "+JSON.stringify(t));if(u&&m?t=t.wholeText:u&&p&&(t=[...t]),c&&m)return i.nodeValue!==t&&(i.nodeValue=t),n;if(m&&(!i||!c)){let l=document.createTextNode(t);return i?(i.onUnmount&&e.patch(i.onUnmount(i)),i.replaceWith(l)):o.childNodes[s]?o.insertBefore(l,o.childNodes[s]):o.appendChild(l),l}if(p&&(!i||c||n[0]!==t[0])){let l=t;1 in l&&(l[1]=M(e,l[1],void 0));let S=b(t);S?.xmlns!==void 0&&(a=S.xmlns);let f=a?document.createElementNS(a,t[0]):document.createElement(t[0]);t.node=f,N(e,f,void 0,S,a),S&&"catch"in S&&(t.node.catch=null,t.node.removeAttribute("catch")),i?(i.onUnmount&&e.patch(i.onUnmount(i)),i.replaceWith(f)):o.childNodes[s]?o.insertBefore(f,o.childNodes[s]):o.appendChild(f);let g=C(t);if(g){let x=S?2:1;for(let T=0;T<g.length;T++){let h=g[T],d=P(e,f,T,void 0,h,a);t[T+x]=d}}return f.onMount&&e.patch(f.onMount(f)),t}if(!c&&p&&n[0]===t[0]){t.node=i;let l=t,S=n,f=b(t),g=b(n);if(f?.xmlns!==void 0&&(a=f.xmlns),l[1]?.__memo){let h=l[1];l[1]=M(e,l[1],S[1]),h!==l[1]&&N(e,i,g,f,a)}else N(e,i,g,f,a);f?.catch&&g?.catch!==f.catch&&(t.node.catch=null,t.node.removeAttribute("catch"));let x=C(t),T=C(n);if(x){let h=f?2:1;for(let d=0;d<x.length;d++){let k=x[d],j=T&&T[d],D=P(e,i,d,j,k,a);D&&(t[d+h]=D)}}if(T){let h=x?x.length:0;for(let d=T.length-1;d>=h;d--)P(e,i,d,T[d],void 0,a)}return t}}catch(r){let c=b(t)?.catch;if(c){let i=typeof c=="function"?c(e,r):c;return P(e,o,s,R(t?.node||n?.node,!0),i,a)}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 M(e,o,s){if(typeof o!="function")return o;let n=o?.__memo,t=s?.__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 s}let a=v(o,e);return typeof a=="object"&&(a.__memo=o?.__memo),a}function v(e,o){return typeof e=="function"?v(e(o),o):e}function N(e,o,s,n,t){if(!n&&!s)return;let a=t!==void 0;if(s)for(let r in s){let c=s[r],i=n?.[r];c!==i&&(n?n[r]=A(e,o,r,c,i,a):A(e,o,r,c,void 0,a))}if(n&&s){for(let r in n)if(!(r in s)){let c=n[r];n[r]=A(e,o,r,void 0,c,a)}}else if(n)for(let r in n){let c=n[r];n[r]=A(e,o,r,void 0,c,a)}}function A(e,o,s,n,t,a){if(s==="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 r in n)t[r]||(o.style[r]=null);for(let r in t){let c=n[r],i=t[r];c!==i&&(o.style[r]=i)}}else for(let r in t)o.style[r]=t[r];else if(s==="class")t?o.setAttribute("class",L(t)):o.removeAttribute("class");else if(s[0]==="o"&&s[1]==="n")if(t){let r=null;if(typeof t=="function"){let c=t;r=i=>e.patch(c(e,i))}else typeof t=="object"&&(r=()=>e.patch(t));o[s]=r}else o[s]=null;else a||(o[s]=t),t==null||t===!1?o.removeAttribute(s):o.setAttribute(s,t);return t}function L(e){return typeof e=="string"?e:Array.isArray(e)?e.map(L).join(" "):typeof e=="object"?Object.keys(e).filter(o=>e[o]).join(" "):""}var J="a",Q="abbr",z="address",Z="area",tt="article",et="aside",nt="audio",ot="b",st="base",at="bdi",rt="bdo",ct="blockquote",it="body",pt="br",lt="button",ft="canvas",St="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",ne="map",oe="mark",se="menu",ae="meta",re="meter",ce="nav",ie="noscript",pe="object",le="ol",fe="optgroup",Se="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",tn="animate",en="animateMotion",nn="animateTransform",on="circle",sn="clipPath",an="defs",rn="desc",cn="ellipse",pn="feBlend",ln="feColorMatrix",fn="feComponentTransfer",Sn="feComposite",dn="feConvolveMatrix",un="feDiffuseLighting",Tn="feDisplacementMap",yn="feDistantLight",gn="feDropShadow",xn="feFlood",hn="feFuncA",mn="feFuncB",En="feFuncG",bn="feFuncR",Pn="feGaussianBlur",An="feImage",Cn="feMerge",Mn="feMergeNode",Nn="feMorphology",Rn="feOffset",On="fePointLight",Dn="feSpecularLighting",vn="feSpotLight",Ln="feTile",In="feTurbulence",Vn="filter",Fn="foreignObject",kn="g",jn="image",Hn="line",Un="linearGradient",Gn="marker",Kn="mask",Bn="metadata",_n="mpath",qn="path",Xn="pattern",$n="polygon",wn="polyline",Yn="radialGradient",Wn="rect",Jn="set",Qn="stop",zn="svg",Zn="switch",to="symbol",eo="text",no="textPath",oo="tspan",so="use",ao="view",ro="annotation",co="annotation-xml",io="maction",po="math",lo="merror",fo="mfrac",So="mi",uo="mmultiscripts",To="mn",yo="mo",go="mover",xo="mpadded",ho="mphantom",mo="mprescripts",Eo="mroot",bo="mrow",Po="ms",Ao="mspace",Co="msqrt",Mo="mstyle",No="msub",Ro="msubsup",Oo="msup",Do="mtable",vo="mtd",Lo="mtext",Io="mtr",Vo="munder",Fo="munderover",ko="semantics";function Ho(...e){if(!e||e.length===0)return null;if(e.length===1)return e[0];let o=e[0];for(let s=1;s<e.length;s++){let n=o,t=e[s];if(!n)o=t;else if(t)if(typeof n=="string"&&typeof t=="string"){let a=n.split(" "),r=t.split(" "),c=new Set([...a,...r]);o=Array.from(c).join(" ").trim()}else if(typeof n=="string"&&Array.isArray(t)){let a=new Set([...t,...n.split(" ")]);o=Array.from(a).join(" ").trim()}else if(Array.isArray(n)&&typeof t=="string"){let a=new Set([...n,...t.split(" ")]);o=Array.from(a).join(" ").trim()}else if(Array.isArray(n)&&Array.isArray(t)){let a=new Set([...n,...t]);o=Array.from(a).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 a={...n};for(let r of t)a[r]=!0;o=a}else if(Array.isArray(n)&&typeof t=="object"){let a={};for(let r of n)a[r]=!0;for(let r of Object.keys(t))a[r]=t[r];o=a}else throw new Error(`cannot merge classes of ${n} (${typeof n}) and ${t} (${typeof t})`);else continue}return o}var I=document.createElement("div");function Go(...e){try{let o=I.style;for(let s of e)if(typeof s=="object"&&s!==null)for(let n in s)o[n]=s[n];else typeof s=="string"&&(o.cssText+=";"+s);return o.cssText}finally{I.style.cssText=""}}var V=class{constructor(o,s){this.state=o;this.path=s;this.keys=s.split(".")}keys;get(){let o=this.keys,s=this.state?this.state[o[0]]:void 0;for(let n=1;n<o.length&&s;n++)s=s[o[n]];return s}put(o){this.putDeep(o,this.state)}patch(o){if(Array.isArray(o)){let s=[];for(let n of o)s.push(this.createPatch(n));this.state.patch(s)}else this.state.patch(this.createPatch(o))}createPatch(o){let s={};return this.putDeep(o,s),s}putDeep(o,s){let n=this.keys;if(n.length>1){let t=0,a=s[n[t]];for((typeof a!="object"||a===null)&&(s[n[t]]=a={}),t=1;t<n.length-1;t++){let r=a;a=a[n[t]],(typeof a!="object"||a===null)&&(r[n[t]]=a={})}a[n[t]]=o}else typeof s[n[0]]=="object"&&typeof o=="object"?Object.assign(s[n[0]],o):s[n[0]]=o}},F=class{constructor(o,s,n,t){this.state=o;this.get=s;this.put=n;this.patch=t}};export{J as A,Q as ABBR,z as ADDRESS,tn as ANIMATE,en as ANIMATEMOTION,nn as ANIMATETRANSFORM,ro as ANNOTATION,co as ANNOTATION_XML,Z as AREA,tt as ARTICLE,et as ASIDE,nt as AUDIO,ot as B,st as BASE,at as BDI,rt as BDO,ct as BLOCKQUOTE,it as BODY,pt as BR,lt as BUTTON,ft as CANVAS,St as CAPTION,on as CIRCLE,dt as CITE,sn as CLIPPATH,ut as CODE,Tt as COL,yt as COLGROUP,gt as DATA,xt as DATALIST,ht as DD,an as DEFS,mt as DEL,rn as DESC,Et as DETAILS,bt as DFN,Pt as DIALOG,At as DIV,Ct as DL,Mt as DT,F as DelegateStateContext,cn as ELLIPSE,Nt as EM,Rt as EMBED,pn as FEBLEND,ln as FECOLORMATRIX,fn as FECOMPONENTTRANSFER,Sn as FECOMPOSITE,dn as FECONVOLVEMATRIX,un as FEDIFFUSELIGHTING,Tn as FEDISPLACEMENTMAP,yn as FEDISTANTLIGHT,gn as FEDROPSHADOW,xn as FEFLOOD,hn as FEFUNCA,mn as FEFUNCB,En as FEFUNCG,bn as FEFUNCR,Pn as FEGAUSSIANBLUR,An as FEIMAGE,Cn as FEMERGE,Mn as FEMERGENODE,Nn as FEMORPHOLOGY,Rn as FEOFFSET,On as FEPOINTLIGHT,Dn as FESPECULARLIGHTING,vn as FESPOTLIGHT,Ln as FETILE,In as FETURBULENCE,Ot as FIELDSET,Dt as FIGCAPTION,vt as FIGURE,Vn as FILTER,Lt as FOOTER,Fn as FOREIGNOBJECT,It as FORM,kn 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,jn as IMAGE,wt as IMG,Yt as INPUT,Wt as INS,Jt as KBD,V as KeyStateContext,Qt as LABEL,zt as LEGEND,Zt as LI,Hn as LINE,Un as LINEARGRADIENT,te as LINK,io as MACTION,ee as MAIN,ne as MAP,oe as MARK,Gn as MARKER,Kn as MASK,po as MATH,se as MENU,lo as MERROR,ae as META,Bn as METADATA,re as METER,fo as MFRAC,So as MI,uo as MMULTISCRIPTS,To as MN,yo as MO,go as MOVER,xo as MPADDED,_n as MPATH,ho as MPHANTOM,mo as MPRESCRIPTS,Eo as MROOT,bo as MROW,Po as MS,Ao as MSPACE,Co as MSQRT,Mo as MSTYLE,No as MSUB,Ro as MSUBSUP,Oo as MSUP,Do as MTABLE,vo as MTD,Lo as MTEXT,Io as MTR,Vo as MUNDER,Fo as MUNDEROVER,ce as NAV,ie as NOSCRIPT,pe as OBJECT,le as OL,fe as OPTGROUP,Se as OPTION,de as OUTPUT,ue as P,qn as PATH,Xn as PATTERN,Te as PICTURE,$n as POLYGON,wn as POLYLINE,ye as PRE,ge as PROGRESS,xe as Q,Yn as RADIALGRADIENT,Wn 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,ko as SEMANTICS,Jn as SET,Re as SLOT,Oe as SMALL,De as SOURCE,ve as SPAN,Qn as STOP,Le as STRONG,Ie as STYLE,Ve as SUB,Fe as SUMMARY,ke as SUP,zn as SVG,Zn as SWITCH,to as SYMBOL,je as TABLE,He as TBODY,Ue as TD,Ge as TEMPLATE,eo as TEXT,Ke as TEXTAREA,no as TEXTPATH,Be as TFOOT,_e as TH,qe as THEAD,Xe as TIME,$e as TITLE,we as TR,Ye as TRACK,oo as TSPAN,We as U,Je as UL,so as USE,Qe as VAR,ze as VIDEO,ao as VIEW,Ze as WBR,K as app,Y as child,w as childCount,C as children,O as childrenStart,X as createPatch,q as createState,B as defuse,E as globals,R as hydrate,_ as memo,Ho as mergeClass,Go as mergeStyle,b as props,$ as tag,G as vode};
package/dist/vode.mjs CHANGED
@@ -20,6 +20,7 @@ function app(container, state, dom, ...initialPatches) {
20
20
  _vode.qSync = null;
21
21
  _vode.qAsync = null;
22
22
  _vode.stats = { lastSyncRenderTime: 0, lastAsyncRenderTime: 0, syncRenderCount: 0, asyncRenderCount: 0, liveEffectCount: 0, patchCount: 0, syncRenderPatchCount: 0, asyncRenderPatchCount: 0 };
23
+ const patchableState = state;
23
24
  Object.defineProperty(state, "patch", {
24
25
  enumerable: false,
25
26
  configurable: true,
@@ -35,28 +36,28 @@ function app(container, state, dom, ...initialPatches) {
35
36
  while (v.done === false) {
36
37
  _vode.stats.liveEffectCount++;
37
38
  try {
38
- _vode.patch(v.value, isAsync);
39
+ patchableState.patch(v.value, isAsync);
39
40
  v = await generator.next();
40
41
  } finally {
41
42
  _vode.stats.liveEffectCount--;
42
43
  }
43
44
  }
44
- _vode.patch(v.value, isAsync);
45
+ patchableState.patch(v.value, isAsync);
45
46
  } finally {
46
47
  _vode.stats.liveEffectCount--;
47
48
  }
48
49
  } else if (action.then) {
49
50
  _vode.stats.liveEffectCount++;
50
51
  try {
51
- const nextState = await action;
52
- _vode.patch(nextState, isAsync);
52
+ const resolvedPatch = await action;
53
+ patchableState.patch(resolvedPatch, isAsync);
53
54
  } finally {
54
55
  _vode.stats.liveEffectCount--;
55
56
  }
56
57
  } else if (Array.isArray(action)) {
57
58
  if (action.length > 0) {
58
59
  for (const p of action) {
59
- _vode.patch(p, !document.hidden && !!_vode.asyncRenderer);
60
+ patchableState.patch(p, !document.hidden && !!_vode.asyncRenderer);
60
61
  }
61
62
  } else {
62
63
  _vode.qSync = mergeState(_vode.qSync || {}, _vode.qAsync, false);
@@ -69,7 +70,7 @@ function app(container, state, dom, ...initialPatches) {
69
70
  _vode.renderSync();
70
71
  }
71
72
  } else if (typeof action === "function") {
72
- _vode.patch(action(_vode.state), isAsync);
73
+ patchableState.patch(action(_vode.state), isAsync);
73
74
  } else {
74
75
  if (isAsync) {
75
76
  _vode.stats.asyncRenderPatchCount++;
@@ -86,7 +87,7 @@ function app(container, state, dom, ...initialPatches) {
86
87
  function renderDom(isAsync) {
87
88
  const sw = Date.now();
88
89
  const vom = dom(_vode.state);
89
- _vode.vode = render(_vode.state, _vode.patch, container.parentElement, 0, _vode.vode, vom);
90
+ _vode.vode = render(_vode.state, container.parentElement, 0, _vode.vode, vom);
90
91
  if (container.tagName.toUpperCase() !== vom[0].toUpperCase()) {
91
92
  container = _vode.vode.node;
92
93
  container._vode = _vode;
@@ -135,22 +136,20 @@ function app(container, state, dom, ...initialPatches) {
135
136
  if (_vode.qAsync) _vode.renderAsync();
136
137
  }
137
138
  });
138
- _vode.patch = state.patch;
139
- _vode.state = state;
139
+ _vode.state = patchableState;
140
140
  const root = container;
141
141
  root._vode = _vode;
142
142
  _vode.vode = render(
143
143
  state,
144
- _vode.patch,
145
144
  container.parentElement,
146
145
  Array.from(container.parentElement.children).indexOf(container),
147
146
  hydrate(container, true),
148
147
  dom(state)
149
148
  );
150
149
  for (const effect of initialPatches) {
151
- _vode.patch(effect);
150
+ patchableState.patch(effect);
152
151
  }
153
- return _vode.patch;
152
+ return (action) => patchableState.patch(action);
154
153
  }
155
154
  function defuse(container) {
156
155
  if (container?._vode) {
@@ -293,7 +292,7 @@ function mergeState(target, source, allowDeletion) {
293
292
  }
294
293
  return target;
295
294
  }
296
- function render(state, patch, parent, childIndex, oldVode, newVode, xmlns) {
295
+ function render(state, parent, childIndex, oldVode, newVode, xmlns) {
297
296
  try {
298
297
  newVode = remember(state, newVode, oldVode);
299
298
  const isNoVode = !newVode || typeof newVode === "number" || typeof newVode === "boolean";
@@ -303,7 +302,7 @@ function render(state, patch, parent, childIndex, oldVode, newVode, xmlns) {
303
302
  const oldIsText = oldVode?.nodeType === Node.TEXT_NODE;
304
303
  const oldNode = oldIsText ? oldVode : oldVode?.node;
305
304
  if (isNoVode) {
306
- oldNode?.onUnmount && patch(oldNode.onUnmount(oldNode));
305
+ oldNode?.onUnmount && state.patch(oldNode.onUnmount(oldNode));
307
306
  oldNode?.remove();
308
307
  return void 0;
309
308
  }
@@ -326,7 +325,7 @@ function render(state, patch, parent, childIndex, oldVode, newVode, xmlns) {
326
325
  if (isText && (!oldNode || !oldIsText)) {
327
326
  const text = document.createTextNode(newVode);
328
327
  if (oldNode) {
329
- oldNode.onUnmount && patch(oldNode.onUnmount(oldNode));
328
+ oldNode.onUnmount && state.patch(oldNode.onUnmount(oldNode));
330
329
  oldNode.replaceWith(text);
331
330
  } else {
332
331
  if (parent.childNodes[childIndex]) {
@@ -343,16 +342,16 @@ function render(state, patch, parent, childIndex, oldVode, newVode, xmlns) {
343
342
  newvode[1] = remember(state, newvode[1], void 0);
344
343
  }
345
344
  const properties = props(newVode);
346
- xmlns = properties?.xmlns || xmlns;
345
+ if (properties?.xmlns !== void 0) xmlns = properties.xmlns;
347
346
  const newNode = xmlns ? document.createElementNS(xmlns, newVode[0]) : document.createElement(newVode[0]);
348
347
  newVode.node = newNode;
349
- patchProperties(state, patch, newNode, void 0, properties);
348
+ patchProperties(state, newNode, void 0, properties, xmlns);
350
349
  if (!!properties && "catch" in properties) {
351
350
  newVode.node["catch"] = null;
352
351
  newVode.node.removeAttribute("catch");
353
352
  }
354
353
  if (oldNode) {
355
- oldNode.onUnmount && patch(oldNode.onUnmount(oldNode));
354
+ oldNode.onUnmount && state.patch(oldNode.onUnmount(oldNode));
356
355
  oldNode.replaceWith(newNode);
357
356
  } else {
358
357
  if (parent.childNodes[childIndex]) {
@@ -361,15 +360,16 @@ function render(state, patch, parent, childIndex, oldVode, newVode, xmlns) {
361
360
  parent.appendChild(newNode);
362
361
  }
363
362
  }
364
- const newChildren = children(newVode);
365
- if (newChildren) {
366
- for (let i = 0; i < newChildren.length; i++) {
367
- const child2 = newChildren[i];
368
- const attached = render(state, patch, newNode, i, void 0, child2, xmlns);
369
- newVode[properties ? i + 2 : i + 1] = attached;
363
+ const newKids = children(newVode);
364
+ if (newKids) {
365
+ const childOffset = !!properties ? 2 : 1;
366
+ for (let i = 0; i < newKids.length; i++) {
367
+ const child2 = newKids[i];
368
+ const attached = render(state, newNode, i, void 0, child2, xmlns);
369
+ newVode[i + childOffset] = attached;
370
370
  }
371
371
  }
372
- newNode.onMount && patch(newNode.onMount(newNode));
372
+ newNode.onMount && state.patch(newNode.onMount(newNode));
373
373
  return newVode;
374
374
  }
375
375
  if (!oldIsText && isNode && oldVode[0] === newVode[0]) {
@@ -377,16 +377,16 @@ function render(state, patch, parent, childIndex, oldVode, newVode, xmlns) {
377
377
  const newvode = newVode;
378
378
  const oldvode = oldVode;
379
379
  const properties = props(newVode);
380
- let hasProps = !!properties;
381
380
  const oldProps = props(oldVode);
381
+ if (properties?.xmlns !== void 0) xmlns = properties.xmlns;
382
382
  if (newvode[1]?.__memo) {
383
383
  const prev = newvode[1];
384
384
  newvode[1] = remember(state, newvode[1], oldvode[1]);
385
385
  if (prev !== newvode[1]) {
386
- patchProperties(state, patch, oldNode, oldProps, properties);
386
+ patchProperties(state, oldNode, oldProps, properties, xmlns);
387
387
  }
388
388
  } else {
389
- patchProperties(state, patch, oldNode, oldProps, properties);
389
+ patchProperties(state, oldNode, oldProps, properties, xmlns);
390
390
  }
391
391
  if (!!properties?.catch && oldProps?.catch !== properties.catch) {
392
392
  newVode.node["catch"] = null;
@@ -395,19 +395,20 @@ function render(state, patch, parent, childIndex, oldVode, newVode, xmlns) {
395
395
  const newKids = children(newVode);
396
396
  const oldKids = children(oldVode);
397
397
  if (newKids) {
398
+ const childOffset = !!properties ? 2 : 1;
398
399
  for (let i = 0; i < newKids.length; i++) {
399
400
  const child2 = newKids[i];
400
401
  const oldChild = oldKids && oldKids[i];
401
- const attached = render(state, patch, oldNode, i, oldChild, child2, xmlns);
402
+ const attached = render(state, oldNode, i, oldChild, child2, xmlns);
402
403
  if (attached) {
403
- newVode[hasProps ? i + 2 : i + 1] = attached;
404
+ newVode[i + childOffset] = attached;
404
405
  }
405
406
  }
406
407
  }
407
408
  if (oldKids) {
408
409
  const newKidsCount = newKids ? newKids.length : 0;
409
410
  for (let i = oldKids.length - 1; i >= newKidsCount; i--) {
410
- render(state, patch, oldNode, i, oldKids[i], void 0, xmlns);
411
+ render(state, oldNode, i, oldKids[i], void 0, xmlns);
411
412
  }
412
413
  }
413
414
  return newVode;
@@ -418,7 +419,6 @@ function render(state, patch, parent, childIndex, oldVode, newVode, xmlns) {
418
419
  const handledVode = typeof catchVode === "function" ? catchVode(state, error) : catchVode;
419
420
  return render(
420
421
  state,
421
- patch,
422
422
  parent,
423
423
  childIndex,
424
424
  hydrate(newVode?.node || oldVode?.node, true),
@@ -465,15 +465,18 @@ function unwrap(c, s) {
465
465
  return c;
466
466
  }
467
467
  }
468
- function patchProperties(s, patch, node, oldProps, newProps) {
468
+ function patchProperties(s, node, oldProps, newProps, xmlns) {
469
469
  if (!newProps && !oldProps) return;
470
+ const xmlMode = xmlns !== void 0;
470
471
  if (oldProps) {
471
472
  for (const key in oldProps) {
472
473
  const oldValue = oldProps[key];
473
474
  const newValue = newProps?.[key];
474
475
  if (oldValue !== newValue) {
475
- if (newProps) newProps[key] = patchProperty(s, patch, node, key, oldValue, newValue);
476
- else patchProperty(s, patch, node, key, oldValue, void 0);
476
+ if (newProps)
477
+ newProps[key] = patchProperty(s, node, key, oldValue, newValue, xmlMode);
478
+ else
479
+ patchProperty(s, node, key, oldValue, void 0, xmlMode);
477
480
  }
478
481
  }
479
482
  }
@@ -481,17 +484,17 @@ function patchProperties(s, patch, node, oldProps, newProps) {
481
484
  for (const key in newProps) {
482
485
  if (!(key in oldProps)) {
483
486
  const newValue = newProps[key];
484
- newProps[key] = patchProperty(s, patch, node, key, void 0, newValue);
487
+ newProps[key] = patchProperty(s, node, key, void 0, newValue, xmlMode);
485
488
  }
486
489
  }
487
490
  } else if (newProps) {
488
491
  for (const key in newProps) {
489
492
  const newValue = newProps[key];
490
- newProps[key] = patchProperty(s, patch, node, key, void 0, newValue);
493
+ newProps[key] = patchProperty(s, node, key, void 0, newValue, xmlMode);
491
494
  }
492
495
  }
493
496
  }
494
- function patchProperty(s, patch, node, key, oldValue, newValue) {
497
+ function patchProperty(s, node, key, oldValue, newValue, xmlMode) {
495
498
  if (key === "style") {
496
499
  if (!newValue) {
497
500
  node.style.cssText = "";
@@ -527,16 +530,16 @@ function patchProperty(s, patch, node, key, oldValue, newValue) {
527
530
  let eventHandler = null;
528
531
  if (typeof newValue === "function") {
529
532
  const action = newValue;
530
- eventHandler = (evt) => patch(action(s, evt));
533
+ eventHandler = (evt) => s.patch(action(s, evt));
531
534
  } else if (typeof newValue === "object") {
532
- eventHandler = () => patch(newValue);
535
+ eventHandler = () => s.patch(newValue);
533
536
  }
534
537
  node[key] = eventHandler;
535
538
  } else {
536
539
  node[key] = null;
537
540
  }
538
541
  } else {
539
- node[key] = newValue;
542
+ if (!xmlMode) node[key] = newValue;
540
543
  if (newValue === void 0 || newValue === null || newValue === false)
541
544
  node.removeAttribute(key);
542
545
  else
@@ -809,6 +812,26 @@ function mergeClass(...classes) {
809
812
  return finalClass;
810
813
  }
811
814
 
815
+ // src/merge-style.ts
816
+ var tempDivForStyling = document.createElement("div");
817
+ function mergeStyle(...props2) {
818
+ try {
819
+ const merged = tempDivForStyling.style;
820
+ for (const style of props2) {
821
+ if (typeof style === "object" && style !== null) {
822
+ for (const key in style) {
823
+ merged[key] = style[key];
824
+ }
825
+ } else if (typeof style === "string") {
826
+ merged.cssText += ";" + style;
827
+ }
828
+ }
829
+ return merged.cssText;
830
+ } finally {
831
+ tempDivForStyling.style.cssText = "";
832
+ }
833
+ }
834
+
812
835
  // src/state-context.ts
813
836
  var KeyStateContext = class {
814
837
  constructor(state, path) {
@@ -1105,6 +1128,7 @@ export {
1105
1128
  hydrate,
1106
1129
  memo,
1107
1130
  mergeClass,
1131
+ mergeStyle,
1108
1132
  props,
1109
1133
  tag,
1110
1134
  vode
package/index.ts CHANGED
@@ -3,4 +3,5 @@ export * from "./src/vode.js";
3
3
  // utilities
4
4
  export * from "./src/vode-tags.js";
5
5
  export * from "./src/merge-class.js";
6
+ export * from "./src/merge-style.js";
6
7
  export * from "./src/state-context.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryupold/vode",
3
- "version": "1.5.2",
3
+ "version": "1.6.1",
4
4
  "description": "a minimalist web framework",
5
5
  "author": "Michael Scherbakow (ryupold)",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "watch": "tsc -b -w"
37
37
  },
38
38
  "devDependencies": {
39
- "esbuild": "0.25.12",
39
+ "esbuild": "0.27.0",
40
40
  "typescript": "5.9.3"
41
41
  }
42
42
  }
@@ -0,0 +1,23 @@
1
+ import { StyleProp } from "./vode.js";
2
+
3
+ const tempDivForStyling = document.createElement('div');
4
+
5
+ /** merge `StyleProps`s regardless of type
6
+ * @returns {string} merged StyleProp */
7
+ export function mergeStyle(...props: StyleProp[]): StyleProp {
8
+ try{
9
+ const merged = tempDivForStyling.style;
10
+ for (const style of props) {
11
+ if (typeof style === 'object' && style !== null) {
12
+ for (const key in style) {
13
+ merged[key] = style[key];
14
+ }
15
+ } else if (typeof style === 'string') {
16
+ merged.cssText += ';' + style;
17
+ }
18
+ }
19
+ return merged.cssText;
20
+ } finally {
21
+ tempDivForStyling.style.cssText = '';
22
+ }
23
+ }
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 */
@@ -86,7 +87,6 @@ export type ContainerNode<S = PatchableState> = HTMLElement & {
86
87
  _vode: {
87
88
  state: PatchableState<S>,
88
89
  vode: AttachedVode<S>,
89
- patch: Dispatch<S>,
90
90
  renderSync: () => void,
91
91
  renderAsync: () => Promise<unknown>,
92
92
  syncRenderer: (cb: () => void) => void,
@@ -131,18 +131,25 @@ export function vode<S = PatchableState>(tag: Tag | Vode<S>, props?: Props<S> |
131
131
  * @param initialPatches variadic list of patches that are applied after the first render
132
132
  * @returns a patch function that can be used to update the state
133
133
  */
134
- export function app<S = PatchableState>(container: Element, state: Omit<S, "patch">, dom: (s: S) => Vode<S>, ...initialPatches: Patch<S>[]) {
134
+ export function app<S extends PatchableState = PatchableState>(
135
+ container: Element,
136
+ state: Omit<S, "patch">,
137
+ dom: (s: S) => Vode<S>,
138
+ ...initialPatches: Patch<S>[]
139
+ ): Dispatch<S> {
135
140
  if (!container?.parentElement) throw new Error("first argument to app() must be a valid HTMLElement inside the <html></html> document");
136
141
  if (!state || typeof state !== "object") throw new Error("second argument to app() must be a state object");
137
142
  if (typeof dom !== "function") throw new Error("third argument to app() must be a function that returns a vode");
138
143
 
139
- const _vode = {} as ContainerNode<S>["_vode"] & { patch: (action: Patch<S>, animate?: boolean) => void };
144
+ const _vode = {} as ContainerNode<S>["_vode"];
140
145
  _vode.syncRenderer = globals.requestAnimationFrame;
141
146
  _vode.asyncRenderer = globals.startViewTransition;
142
147
  _vode.qSync = null;
143
148
  _vode.qAsync = null;
144
149
  _vode.stats = { lastSyncRenderTime: 0, lastAsyncRenderTime: 0, syncRenderCount: 0, asyncRenderCount: 0, liveEffectCount: 0, patchCount: 0, syncRenderPatchCount: 0, asyncRenderPatchCount: 0 };
145
150
 
151
+ const patchableState = state as PatchableState<S> & { patch: (action: Patch<S>, animate?: boolean) => void };
152
+
146
153
  Object.defineProperty(state, "patch", {
147
154
  enumerable: false, configurable: true,
148
155
  writable: false, value: async (action: Patch<S>, isAsync?: boolean) => {
@@ -157,28 +164,28 @@ export function app<S = PatchableState>(container: Element, state: Omit<S, "patc
157
164
  while (v.done === false) {
158
165
  _vode.stats.liveEffectCount++;
159
166
  try {
160
- _vode.patch!(v.value, isAsync);
167
+ patchableState.patch(v.value, isAsync);
161
168
  v = await generator.next();
162
169
  } finally {
163
170
  _vode.stats.liveEffectCount--;
164
171
  }
165
172
  }
166
- _vode.patch!(v.value as Patch<S>, isAsync);
173
+ patchableState.patch(v.value as Patch<S>, isAsync);
167
174
  } finally {
168
175
  _vode.stats.liveEffectCount--;
169
176
  }
170
177
  } else if ((action as Promise<S>).then) {
171
178
  _vode.stats.liveEffectCount++;
172
179
  try {
173
- const nextState = await (action as Promise<S>);
174
- _vode.patch!(<Patch<S>>nextState, isAsync);
180
+ const resolvedPatch = await (action as Promise<S>);
181
+ patchableState.patch(<Patch<S>>resolvedPatch, isAsync);
175
182
  } finally {
176
183
  _vode.stats.liveEffectCount--;
177
184
  }
178
185
  } else if (Array.isArray(action)) {
179
186
  if (action.length > 0) {
180
187
  for (const p of action) {
181
- _vode.patch(p, !document.hidden && !!_vode.asyncRenderer);
188
+ patchableState.patch(p, !document.hidden && !!_vode.asyncRenderer);
182
189
  }
183
190
  } else { //when [] is patched: 1. skip current animation 2. merge all queued async patches into synced queue
184
191
  _vode.qSync = mergeState(_vode.qSync || {}, _vode.qAsync, false);
@@ -188,7 +195,7 @@ export function app<S = PatchableState>(container: Element, state: Omit<S, "patc
188
195
  _vode.renderSync();
189
196
  }
190
197
  } else if (typeof action === "function") {
191
- _vode.patch!((<(s: S) => unknown>action)(_vode.state), isAsync);
198
+ patchableState.patch((<(s: S) => unknown>action)(_vode.state), isAsync);
192
199
  } else {
193
200
  if (isAsync) {
194
201
  _vode.stats.asyncRenderPatchCount++;
@@ -206,7 +213,7 @@ export function app<S = PatchableState>(container: Element, state: Omit<S, "patc
206
213
  function renderDom(isAsync: boolean) {
207
214
  const sw = Date.now();
208
215
  const vom = dom(_vode.state);
209
- _vode.vode = render(_vode.state, _vode.patch, container.parentElement as Element, 0, _vode.vode, vom)!;
216
+ _vode.vode = render<S>(_vode.state, container.parentElement as Element, 0, _vode.vode, vom)!;
210
217
 
211
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
212
219
  container = _vode.vode.node as Element;
@@ -262,15 +269,13 @@ export function app<S = PatchableState>(container: Element, state: Omit<S, "patc
262
269
  }
263
270
  });
264
271
 
265
- _vode.patch = (<PatchableState<S>>state).patch;
266
- _vode.state = <PatchableState<S>>state;
272
+ _vode.state = patchableState;
267
273
 
268
274
  const root = container as ContainerNode<S>;
269
275
  root._vode = _vode;
270
276
 
271
277
  _vode.vode = render(
272
278
  <S>state,
273
- _vode.patch!,
274
279
  container.parentElement,
275
280
  Array.from(container.parentElement.children).indexOf(container),
276
281
  hydrate<S>(container, true) as AttachedVode<S>,
@@ -278,10 +283,10 @@ export function app<S = PatchableState>(container: Element, state: Omit<S, "patc
278
283
  )!;
279
284
 
280
285
  for (const effect of initialPatches) {
281
- _vode.patch!(effect);
286
+ patchableState.patch(effect);
282
287
  }
283
288
 
284
- return _vode.patch;
289
+ return (action: Patch<S>) => patchableState.patch(action);
285
290
  }
286
291
 
287
292
  /** unregister vode app from container and free resources
@@ -467,7 +472,7 @@ function mergeState(target: any, source: any, allowDeletion: boolean) {
467
472
  return target;
468
473
  };
469
474
 
470
- function render<S>(state: S, patch: Dispatch<S>, parent: Element, childIndex: number, oldVode: AttachedVode<S> | undefined, newVode: ChildVode<S>, xmlns?: string): AttachedVode<S> | undefined {
475
+ function render<S extends PatchableState>(state: S, parent: Element, childIndex: number, oldVode: AttachedVode<S> | undefined, newVode: ChildVode<S>, xmlns?: string | null): AttachedVode<S> | undefined {
471
476
  try {
472
477
  // unwrap component if it is memoized
473
478
  newVode = remember(state, newVode, oldVode) as ChildVode<S>;
@@ -482,7 +487,7 @@ function render<S>(state: S, patch: Dispatch<S>, parent: Element, childIndex: nu
482
487
 
483
488
  // falsy|text|element(A) -> undefined
484
489
  if (isNoVode) {
485
- (<any>oldNode)?.onUnmount && patch((<any>oldNode).onUnmount(oldNode));
490
+ (<any>oldNode)?.onUnmount && state.patch((<any>oldNode).onUnmount(oldNode));
486
491
  oldNode?.remove();
487
492
  return undefined;
488
493
  }
@@ -512,7 +517,7 @@ function render<S>(state: S, patch: Dispatch<S>, parent: Element, childIndex: nu
512
517
  if (isText && (!oldNode || !oldIsText)) {
513
518
  const text = document.createTextNode(newVode as string)
514
519
  if (oldNode) {
515
- (<any>oldNode).onUnmount && patch((<any>oldNode).onUnmount(oldNode));
520
+ (<any>oldNode).onUnmount && state.patch((<any>oldNode).onUnmount(oldNode));
516
521
  oldNode.replaceWith(text);
517
522
  } else {
518
523
  if (parent.childNodes[childIndex]) {
@@ -535,13 +540,14 @@ function render<S>(state: S, patch: Dispatch<S>, parent: Element, childIndex: nu
535
540
 
536
541
  const properties = props(newVode);
537
542
 
538
- xmlns = properties?.xmlns as string || xmlns;
543
+ if (properties?.xmlns !== undefined) xmlns = properties.xmlns;
544
+
539
545
  const newNode: ChildNode = xmlns
540
546
  ? document.createElementNS(xmlns, (<Vode<S>>newVode)[0])
541
547
  : document.createElement((<Vode<S>>newVode)[0]);
542
548
  (<AttachedVode<S>>newVode).node = newNode;
543
549
 
544
- patchProperties(state, patch, newNode, undefined, properties);
550
+ patchProperties(state, newNode, undefined, properties, xmlns);
545
551
 
546
552
  if (!!properties && 'catch' in properties) {
547
553
  (<any>newVode).node['catch'] = null;
@@ -549,7 +555,7 @@ function render<S>(state: S, patch: Dispatch<S>, parent: Element, childIndex: nu
549
555
  }
550
556
 
551
557
  if (oldNode) {
552
- (<any>oldNode).onUnmount && patch((<any>oldNode).onUnmount(oldNode));
558
+ (<any>oldNode).onUnmount && state.patch((<any>oldNode).onUnmount(oldNode));
553
559
  oldNode.replaceWith(newNode);
554
560
  } else {
555
561
  if (parent.childNodes[childIndex]) {
@@ -559,16 +565,17 @@ function render<S>(state: S, patch: Dispatch<S>, parent: Element, childIndex: nu
559
565
  }
560
566
  }
561
567
 
562
- const newChildren = children(newVode);
563
- if (newChildren) {
564
- for (let i = 0; i < newChildren.length; i++) {
565
- const child = newChildren[i];
566
- const attached = render(state, patch, newNode as Element, i, undefined, child, xmlns);
567
- (<Vode<S>>newVode!)[properties ? i + 2 : i + 1] = <Vode<S>>attached;
568
+ const newKids = children(newVode);
569
+ if (newKids) {
570
+ const childOffset = !!properties ? 2 : 1;
571
+ for (let i = 0; i < newKids.length; i++) {
572
+ const child = newKids[i];
573
+ const attached = render(state, newNode as Element, i, undefined, child, xmlns);
574
+ (<Vode<S>>newVode!)[i + childOffset] = <Vode<S>>attached;
568
575
  }
569
576
  }
570
577
 
571
- (<any>newNode).onMount && patch((<any>newNode).onMount(newNode));
578
+ (<any>newNode).onMount && state.patch((<any>newNode).onMount(newNode));
572
579
  return <AttachedVode<S>>newVode;
573
580
  }
574
581
 
@@ -580,18 +587,19 @@ function render<S>(state: S, patch: Dispatch<S>, parent: Element, childIndex: nu
580
587
  const oldvode = <Vode<S>>oldVode;
581
588
 
582
589
  const properties = props(newVode);
583
- let hasProps = !!properties;
584
590
  const oldProps = props(oldVode);
585
591
 
592
+ if (properties?.xmlns !== undefined) xmlns = properties.xmlns;
593
+
586
594
  if ((<any>newvode[1])?.__memo) {
587
595
  const prev = newvode[1] as any;
588
596
  newvode[1] = remember(state, newvode[1], oldvode[1]) as Vode<S>;
589
597
  if (prev !== newvode[1]) {
590
- patchProperties(state, patch, oldNode!, oldProps, properties);
598
+ patchProperties(state, oldNode!, oldProps, properties, xmlns);
591
599
  }
592
600
  }
593
601
  else {
594
- patchProperties(state, patch, oldNode!, oldProps, properties);
602
+ patchProperties(state, oldNode!, oldProps, properties, xmlns);
595
603
  }
596
604
 
597
605
  if (!!properties?.catch && oldProps?.catch !== properties.catch) {
@@ -602,13 +610,14 @@ function render<S>(state: S, patch: Dispatch<S>, parent: Element, childIndex: nu
602
610
  const newKids = children(newVode);
603
611
  const oldKids = children(oldVode) as AttachedVode<S>[];
604
612
  if (newKids) {
613
+ const childOffset = !!properties ? 2 : 1;
605
614
  for (let i = 0; i < newKids.length; i++) {
606
615
  const child = newKids[i];
607
616
  const oldChild = oldKids && oldKids[i];
608
617
 
609
- const attached = render(state, patch, oldNode as Element, i, oldChild, child, xmlns);
618
+ const attached = render(state, oldNode as Element, i, oldChild, child, xmlns);
610
619
  if (attached) {
611
- (<Vode<S>>newVode)[hasProps ? i + 2 : i + 1] = <Vode<S>>attached;
620
+ (<Vode<S>>newVode)[i + childOffset] = <Vode<S>>attached;
612
621
  }
613
622
  }
614
623
  }
@@ -616,7 +625,7 @@ function render<S>(state: S, patch: Dispatch<S>, parent: Element, childIndex: nu
616
625
  if (oldKids) {
617
626
  const newKidsCount = newKids ? newKids.length : 0;
618
627
  for (let i = oldKids.length - 1; i >= newKidsCount; i--) {
619
- render(state, patch, oldNode as Element, i, oldKids[i], undefined, xmlns);
628
+ render(state, oldNode as Element, i, oldKids[i], undefined, xmlns);
620
629
  }
621
630
  }
622
631
 
@@ -629,7 +638,7 @@ function render<S>(state: S, patch: Dispatch<S>, parent: Element, childIndex: nu
629
638
  ? (<(s: S, error: any) => ChildVode<S>>catchVode)(state, error)
630
639
  : catchVode;
631
640
 
632
- return render(state, patch, parent, childIndex,
641
+ return render(state, parent, childIndex,
633
642
  hydrate(((<AttachedVode<S>>newVode)?.node || oldVode?.node) as Element, true) as AttachedVode<S>,
634
643
  handledVode,
635
644
  xmlns);
@@ -684,9 +693,15 @@ function unwrap<S>(c: Component<S> | ChildVode<S>, s: S): ChildVode<S> {
684
693
  }
685
694
  }
686
695
 
687
- function patchProperties<S>(s: S, patch: Dispatch<S>, node: ChildNode, oldProps?: Props<S>, newProps?: Props<S>) {
696
+ function patchProperties<S extends PatchableState>(
697
+ s: S, node: ChildNode,
698
+ oldProps: Props<S> | null | undefined, newProps: Props<S> | null | undefined,
699
+ xmlns: string | null | undefined
700
+ ) {
688
701
  if (!newProps && !oldProps) return;
689
702
 
703
+ const xmlMode = xmlns !== undefined;
704
+
690
705
  // match existing properties
691
706
  if (oldProps) {
692
707
  for (const key in oldProps) {
@@ -694,8 +709,10 @@ function patchProperties<S>(s: S, patch: Dispatch<S>, node: ChildNode, oldProps?
694
709
  const newValue = newProps?.[key as keyof Props<S>] as PropertyValue<S>;
695
710
 
696
711
  if (oldValue !== newValue) {
697
- if (newProps) newProps[key as keyof Props<S>] = patchProperty(s, patch, node, key, oldValue, newValue);
698
- else patchProperty(s, patch, node, key, oldValue, undefined);
712
+ if (newProps)
713
+ newProps[key as keyof Props<S>] = patchProperty(s, node, key, oldValue, newValue, xmlMode);
714
+ else
715
+ patchProperty(s, node, key, oldValue, undefined, xmlMode);
699
716
  }
700
717
  }
701
718
  }
@@ -705,7 +722,7 @@ function patchProperties<S>(s: S, patch: Dispatch<S>, node: ChildNode, oldProps?
705
722
  for (const key in newProps) {
706
723
  if (!(key in oldProps)) {
707
724
  const newValue = newProps[key as keyof Props<S>] as PropertyValue<S>;
708
- newProps[key as keyof Props<S>] = patchProperty(s, patch, <Element>node, key, undefined, newValue);
725
+ newProps[key as keyof Props<S>] = patchProperty(s, <Element>node, key, undefined, newValue, xmlMode);
709
726
  }
710
727
  }
711
728
  }
@@ -713,12 +730,12 @@ function patchProperties<S>(s: S, patch: Dispatch<S>, node: ChildNode, oldProps?
713
730
  else if (newProps) {
714
731
  for (const key in newProps) {
715
732
  const newValue = newProps[key as keyof Props<S>] as PropertyValue<S>;
716
- newProps[key as keyof Props<S>] = patchProperty(s, patch, <Element>node, key, undefined, newValue);
733
+ newProps[key as keyof Props<S>] = patchProperty(s, <Element>node, key, undefined, newValue, xmlMode);
717
734
  }
718
735
  }
719
736
  }
720
737
 
721
- function patchProperty<S>(s: S, patch: Dispatch<S>, node: ChildNode, key: string | keyof ElementEventMap, oldValue?: PropertyValue<S>, newValue?: PropertyValue<S>) {
738
+ function patchProperty<S extends PatchableState>(s: S, node: ChildNode, key: string | keyof ElementEventMap, oldValue: PropertyValue<S>, newValue: PropertyValue<S>, xmlMode: boolean) {
722
739
  if (key === "style") {
723
740
  if (!newValue) {
724
741
  (node as HTMLElement).style.cssText = "";
@@ -754,9 +771,9 @@ function patchProperty<S>(s: S, patch: Dispatch<S>, node: ChildNode, key: string
754
771
  let eventHandler: Function | null = null;
755
772
  if (typeof newValue === "function") {
756
773
  const action = newValue as EventFunction<S>;
757
- eventHandler = (evt: Event) => patch(action(s, evt));
774
+ eventHandler = (evt: Event) => s.patch(action(s, evt));
758
775
  } else if (typeof newValue === "object") {
759
- eventHandler = () => patch(newValue as Patch<S>);
776
+ eventHandler = () => s.patch(newValue as Patch<S>);
760
777
  }
761
778
 
762
779
  (<any>node)[key] = eventHandler;
@@ -764,7 +781,7 @@ function patchProperty<S>(s: S, patch: Dispatch<S>, node: ChildNode, key: string
764
781
  (<any>node)[key] = null;
765
782
  }
766
783
  } else {
767
- (<any>node)[key] = newValue;
784
+ if (!xmlMode) (<any>node)[key] = newValue;
768
785
  if (newValue === undefined || newValue === null || newValue === false)
769
786
  (<HTMLElement>node).removeAttribute(key);
770
787
  else