@krate/runtime 0.3.0-beta.2 → 0.3.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dom.js CHANGED
@@ -133,6 +133,8 @@ function setAttr(el, key, value) {
133
133
  else if (key === 'ref') {
134
134
  if (typeof value === 'function')
135
135
  value(el);
136
+ else if (value && typeof value === 'object' && 'current' in value)
137
+ value.current = el;
136
138
  }
137
139
  else if (key === 'key') {
138
140
  // key is metadata only, not set as attribute
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { createSignal, createEffect, createMemo, onCleanup, onMount, forwardRef, disposeAll } from './signal.js';
2
- export { h, mount, hydrate, insert, clearNodes } from './dom.js';
1
+ export { createSignal, createEffect, createMemo, onCleanup, onMount, forwardRef, useRef, disposeAll } from './signal.js';
2
+ export { h, mount, hydrate, insert, clearNodes, disposeNode } from './dom.js';
3
3
  export { Fragment, jsx, jsxs } from './jsx-runtime.js';
4
4
  export { initRouter, reinitRouter } from './router.js';
5
5
  export { createContext, resetContexts } from './context.js';
@@ -7,5 +7,6 @@ export { createResource } from './resource.js';
7
7
  export type { Context } from './context.js';
8
8
  export type { ResourceReturn, ResourceActions } from './resource.js';
9
9
  export type { Component, PropsWithChildren, ComponentProps, RefCallback } from './dom.js';
10
+ export type { RefObject, Ref, UseRefResult } from './signal.js';
10
11
  import './jsx-types.js';
11
12
  import './css-modules.js';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { createSignal, createEffect, createMemo, onCleanup, onMount, forwardRef, disposeAll } from './signal.js';
2
- export { h, mount, hydrate, insert, clearNodes } from './dom.js';
1
+ export { createSignal, createEffect, createMemo, onCleanup, onMount, forwardRef, useRef, disposeAll } from './signal.js';
2
+ export { h, mount, hydrate, insert, clearNodes, disposeNode } from './dom.js';
3
3
  export { Fragment, jsx, jsxs } from './jsx-runtime.js';
4
4
  export { initRouter, reinitRouter } from './router.js';
5
5
  export { createContext, resetContexts } from './context.js';
@@ -1,2 +1,2 @@
1
- var __krate_exports=(()=>{var _=Object.defineProperty,De=Object.defineProperties,Ie=Object.getOwnPropertyDescriptor,Be=Object.getOwnPropertyDescriptors,Ke=Object.getOwnPropertyNames,ae=Object.getOwnPropertySymbols;var de=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable;var ue=(e,t,n)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pe=(e,t)=>{for(var n in t||(t={}))de.call(t,n)&&ue(e,n,t[n]);if(ae)for(var n of ae(t))We.call(t,n)&&ue(e,n,t[n]);return e},he=(e,t)=>De(e,Be(t));var Ve=(e,t)=>{for(var n in t)_(e,n,{get:t[n],enumerable:!0})},Ue=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of Ke(t))!de.call(e,l)&&l!==n&&_(e,l,{get:()=>t[l],enumerable:!(r=Ie(t,l))||r.enumerable});return e};var Fe=e=>Ue(_({},"__esModule",{value:!0}),e);var ft={};Ve(ft,{clearNodes:()=>Te,conditional:()=>it,createEffect:()=>w,createMemo:()=>Ge,createSignal:()=>Ee,disposeAll:()=>je,disposeNode:()=>v,forwardRef:()=>Je,h:()=>tt,hydrate:()=>ot,initRouter:()=>ke,insert:()=>et,mount:()=>nt,onCleanup:()=>Xe,onMount:()=>Ye,reconcile:()=>rt,reconcileTrees:()=>z,reinitRouter:()=>ct});var A=[],me=[],K=!1,M=new Set,W=[],O=!1;function ge(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function V(e){if(!e.disposed){e.disposed=!0;for(let t of e.sources)t.delete(e);e.sources.clear();for(let t of e.cleanups)t();e.cleanups.length=0}}function je(){for(let e of M)V(e);M.clear(),W.length=0,O=!1}function Ee(e){let t=e,n=new Set;return[()=>{let f=A[A.length-1];return f&&!f.disposed&&(n.add(f),f.sources.add(n)),t},f=>{let u=typeof f=="function"?f(t):f;if(u!==t){t=u;let E=Array.from(n);for(let h of E){if(h.disposed){n.delete(h);continue}if(h.running){h.rerun=!0;continue}h.queued||(h.queued=!0,W.push(h))}$e()}}]}function $e(){O||(O=!0,queueMicrotask(ze))}function ze(){O=!1;let e=W.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,q(t),t.rerun&&!t.disposed&&(t.rerun=!1,q(t)))}function q(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,A.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{A.pop(),e.running=!1}}function w(e){let t=ge(e);return M.add(t),q(t),()=>{V(t),M.delete(t)}}function Xe(e){let t=A[A.length-1];t&&t.cleanups.push(e)}function Ye(e){me.push(e),K||(K=!0,queueMicrotask(Qe))}function Qe(){K=!1;let e=me.splice(0);for(let t of e)t()}function Ge(e){let[t,n]=Ee(void 0),r=ge(()=>{let f=e();n(f)});M.add(r),q(r);let l=A[A.length-1];return l&&l.cleanups.push(()=>{r.disposed||(V(r),M.delete(r))}),t}function Je(e){return t=>e(t,t.ref||(()=>{}))}var U=new WeakMap;function Ne(e,t){let n=U.get(e);n||(n=[],U.set(e,n)),n.push(t)}function v(e){let t=U.get(e);if(t){for(let n of t)n();t.length=0}for(let n=0;n<e.childNodes.length;n++)v(e.childNodes[n])}function Ze(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function Te(e,t){let n=e.parentNode;if(!n)return;let r=e.nextSibling;for(;r&&r!==t;){let l=r.nextSibling;v(r),n.removeChild(r),r=l}}function et(e,t,n){let r=Ze(n);r?(Te(n,r),F(e,t,r)):F(e,t,null)}function F(e,t,n){if(!(t==null||t===!1||t===!0)){if(typeof t=="string"||typeof t=="number")e.insertBefore(document.createTextNode(String(t)),n);else if(t instanceof Node)e.insertBefore(t,n);else if(Array.isArray(t))for(let r of t)F(e,r,n)}}function ye(e,t,n){if(t==="class"||t==="className")n===!1||n===null||n===void 0?e.className="":e.className=String(n);else if(t==="style")typeof n=="string"?e.setAttribute("style",n):n&&typeof n=="object"&&Object.assign(e.style,n);else if(t.startsWith("on")&&typeof n=="function"){let r=t.slice(2).toLowerCase(),l=`__krate_${r}`,f=e[l];f&&e.removeEventListener(r,f),e.addEventListener(r,n),e[l]=n}else t==="ref"?typeof n=="function"&&n(e):t==="key"||n!=null&&n!==!1&&e.setAttribute(t,String(n))}function ve(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)ve(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),Ne(n,w(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function tt(e,t,...n){if(typeof e=="function")return e(he(pe({},t||{}),{children:n}));let r=document.createElement(e);if(t)for(let[l,f]of Object.entries(t))typeof f=="function"&&!l.startsWith("on")?Ne(r,w(()=>ye(r,l,f()))):ye(r,l,f);for(let l of n)ve(r,l);return r}function be(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function nt(e,t){let n=be(t),r=!1;w(()=>{r||(r=!0,n.appendChild(e()))})}function ot(e,t){let n=be(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&v(r)}function rt(e,t,n,r,l,f){let u=[],E=t.nextSibling;for(;E&&E!==n;)u.push(E),E=E.nextSibling;if(f){let h=new Map;for(let d of u){let a=d.__k;a!=null&&h.set(a,d)}let m=[],S=new Set;for(let d=0;d<r.length;d++){let a=r[d],g=f(a);S.add(g);let T=l(a,d);T.__k=g,m.push(T)}for(let[d,a]of h)!S.has(d)&&a.parentNode===e&&(v(a),e.removeChild(a));for(let d=0;d<m.length;d++){let a=m[d],g=d===0?t:m[d-1];a!==g.nextSibling&&e.insertBefore(a,g.nextSibling)}}else{let h=Math.max(u.length,r.length);for(let m=0;m<h;m++)if(m<r.length){let S=l(r[m],m);m<u.length?u[m]!==S&&(v(u[m]),e.replaceChild(S,u[m])):e.insertBefore(S,n)}else m<u.length&&u[m].parentNode===e&&(v(u[m]),e.removeChild(u[m]))}}function it(e,t,n,r,l,f){let u=null;w(()=>{let h=r()?l():f?f():null;u?h?(v(u),e.replaceChild(h,u)):(v(u),e.removeChild(u)):h&&e.insertBefore(h,n),u=h})}function C(e){if(e.nodeType===Node.COMMENT_NODE){let t=e.nodeValue||"";return t.indexOf("k:")===0?t:null}if(e.nodeType===Node.ELEMENT_NODE){let t=e,n=t.getAttribute("data-k");if(n)return n;let r=t.getAttribute("id");if(r)return"#"+r}return null}function Se(e,t){let n=new Set;for(let r=0;r<t.attributes.length;r++){let l=t.attributes[r].name,f=t.attributes[r].value;n.add(l),e.getAttribute(l)!==f&&e.setAttribute(l,f)}for(let r=0;r<e.attributes.length;r++){let l=e.attributes[r].name;n.has(l)||e.removeAttribute(l)}}function j(e,t){let n=document.importNode(t,!0);return e.parentNode&&(v(e),e.parentNode.replaceChild(n,e)),n}function xe(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!0}function $(e,t){if(!xe(e,t))return j(e,t);if(e.nodeType===Node.TEXT_NODE)return e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e;if(e.nodeType===Node.COMMENT_NODE)return e.nodeValue!==t.nodeValue?j(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,r=t;return C(n)!==C(r)?j(n,r):(Se(n,r),Ae(n,r),n)}function Ae(e,t){let n=Array.from(e.childNodes),r=Array.from(t.childNodes);if(n.length===r.length){let d=!0;for(let a=0;a<r.length;a++)if(C(n[a])!==C(r[a])){d=!1;break}if(d){for(let a=0;a<r.length;a++)$(n[a],r[a]);return}}let l=new Map,f=[];n.forEach((d,a)=>{let g=C(d);g!=null?l.has(g)||l.set(g,a):f.push(a)});let u=new Set,E=0,h=null,m=0,S=()=>{for(;m<f.length&&u.has(f[m]);)m++;return m<f.length?f[m]:-1};for(let d of r){let a=C(d),g;if(a!=null&&l.has(a)){let T=l.get(a);l.delete(a),u.add(T);let N=n[T];T<E?e.insertBefore(N,h):E=T,g=$(N,d)}else if(a==null){let T=S();if(T>=0&&xe(n[T],d)){u.add(T);let N=n[T];N.parentNode===e&&N.nextSibling!==h&&e.insertBefore(N,h),g=$(N,d)}else g=document.importNode(d,!0),e.insertBefore(g,h)}else g=document.importNode(d,!0),e.insertBefore(g,h);h=g.nextSibling}n.forEach((d,a)=>{!u.has(a)&&d.parentNode===e&&(v(d),e.removeChild(d))})}function z(e,t){if(e.nodeType!==Node.ELEMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return;let n=e,r=t;if(n.tagName!==r.tagName){let l=document.importNode(t,!0);n.parentNode&&n.parentNode.replaceChild(l,n);return}Se(n,r),Ae(n,r)}var X=!1,H,R=null,k=new Map,st=30,P=new Map,lt=50,we=/\/chunks\/runtime\.[^/]+\.js$/;function ke(){if(typeof document=="undefined"||X)return;X=!0;let e=".docs-content, main, #root",t=150,n=200,r=null,l=null,f=new Map,u=null;function E(o){for(let i of e.split(", ")){let s=o.querySelector(i.trim());if(s)return s}return o.body}function h(o){if(o.hasAttribute("data-krate-external"))return!1;let i=o.getAttribute("href");return!(!i||i.startsWith("#")||i.startsWith("javascript:")||o.origin!==location.origin||o.target==="_blank")}function m(o){k.has(o)||fetch(o,{headers:{Accept:"text/html"}}).then(i=>i.ok?i.text():null).then(i=>{if(i){if(k.size>=st){let s=k.keys().next().value;s!==void 0&&k.delete(s)}k.set(o,i)}}).catch(()=>{})}function S(){document.addEventListener("mouseover",g),document.addEventListener("focusin",g),typeof IntersectionObserver!="undefined"&&(u=new IntersectionObserver(o=>{for(let i of o)if(i.isIntersecting){let s=i.target,c=s.getAttribute("href");if(c&&h(s)){let p=new URL(c,location.origin).href;m(p)}u.unobserve(i.target)}},{rootMargin:"200px"}),d())}function d(){u&&document.querySelectorAll("a[data-prefetch]").forEach(o=>{u.observe(o)})}function a(){document.removeEventListener("mouseover",g),document.removeEventListener("focusin",g);for(let o of f.values())clearTimeout(o);f.clear(),u&&(u.disconnect(),u=null)}function g(o){let i=o.target.closest("a[data-prefetch]");if(!i||!h(i))return;let s=i.getAttribute("href");if(!s)return;let c=new URL(s,location.origin).href;if(k.has(c))return;let p=f.get(i);p&&clearTimeout(p);let y=setTimeout(()=>{f.delete(i),m(c)},n);f.set(i,y)}function T(o){let i=document.createTreeWalker(o,NodeFilter.SHOW_ELEMENT),s=i.nextNode();for(;s;){let c=s;for(let p of Object.keys(c))p.indexOf("__krate_")===0&&delete c[p];s=i.nextNode()}}let N=null;function Le(){let o=E(document),i=document.querySelector("template[data-krate-loading]");i&&i.content&&o&&(N=i.content.cloneNode(!0),document.body.appendChild(N)),o&&(o.style.transition=`opacity ${t}ms ease`,o.style.opacity="0")}function Y(){N&&N.parentNode&&N.parentNode.removeChild(N),N=null;let o=E(document);o&&(o.style.opacity="1")}function Q(o,i,s,c={}){let{replace:p=!1,scroll:y=!0,restoreScroll:L=!1}=c,D=new DOMParser().parseFromString(o,"text/html"),ie=E(D),I=E(document);if(!ie||!I){location.href=i;return}let se=D.querySelector("title");se&&(document.title=se.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),T(I),z(I,ie);let le=D.querySelectorAll('link[rel="stylesheet"]'),ce=new Set;le.forEach(b=>{let x=b.getAttribute("href");x&&ce.add(x)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(b=>{let x=b.getAttribute("href");x&&!ce.has(x)&&b.remove()});let fe=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(b=>{fe.add(b.href)}),le.forEach(b=>{let x=b.getAttribute("href");if(x&&!fe.has(x)){let B=document.createElement("link");B.rel="stylesheet",B.href=x,document.head.appendChild(B)}}),Ce(s,i).then(()=>{Pe(),d()}),Y();let Re=location.pathname+location.search;if(p)history.replaceState({},"",i);else{if(!L){if(P.size>=lt){let b=P.keys().next().value;b!==void 0&&P.delete(b)}P.set(Re,window.scrollY)}history.pushState({},"",i)}G(i,{restoreScroll:L,scroll:y}),J(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:i}}))}function Me(o){let i=o.indexOf("#");if(i<0||i===o.length-1)return!1;let s=o.slice(i);try{let c=document.querySelector(s);if(c)return c.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch(c){return!1}return!1}function G(o,i){if(i.restoreScroll){let s=P.get(o);if(s!==void 0){window.scrollTo(0,s);return}}Me(o)||i.scroll&&window.scrollTo(0,0)}function J(){let o=location.pathname;document.querySelectorAll("a[data-krate-link]").forEach(i=>{let s=i.getAttribute("href");if(!s){i.removeAttribute("aria-current");return}let c=s;try{c=new URL(s,location.origin).pathname}catch(y){return}c===o||o==="/"&&(c===""||c==="/")||c!=="/"&&c.length>1&&o.startsWith(c)?i.setAttribute("aria-current","page"):i.removeAttribute("aria-current")})}function Ce(o,i){return o.length===0?Promise.resolve():Promise.all(o.map(s=>{let c=s.getAttribute("src");return c?He(c,i):Promise.resolve()})).then(()=>{})}function He(o,i){return new Promise(s=>{let c=document.createElement("script"),p=Z(o,i);c.src=p,we.test(p)||c.setAttribute("data-krate-spa",""),c.onload=()=>s(),c.onerror=()=>s(),document.body.appendChild(c)})}function Z(o,i){if(/^(https?:)?\/\//.test(o)||o.startsWith("/"))return new URL(o,i).href;let s=i;if(!s.endsWith("/")){let c=s.lastIndexOf("/");s=c>0?s.slice(0,c+1):"/"}return new URL(o,s).href}function Pe(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function _e(o,i){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",i),document.open(),document.write(o),document.close()}function Oe(){return r!==null?Promise.resolve(r):fetch("/404.html",{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>(r=o,o)).catch(()=>null)}function qe(){return l!==null?Promise.resolve(l):fetch("/500.html",{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>(l=o,o)).catch(()=>null)}function ee(o,i){document.querySelectorAll("script[data-krate-spa]").forEach(p=>p.remove());let s=[],c=new Set;return document.querySelectorAll("script[src]").forEach(p=>{c.add(p.src)}),o.querySelectorAll("script[src]").forEach(p=>{let y=p.getAttribute("src");y&&!c.has(Z(y,i))&&s.push(p)}),s}function te(o,i={}){let s=k.get(o);if(s){let y=new DOMParser().parseFromString(s,"text/html");Q(s,o,ee(y,o),i);return}Le(),H&&H.abort(),H=new AbortController;let c=H.signal;fetch(o,{headers:{Accept:"text/html"},signal:c}).then(p=>p.ok?p.text().then(y=>{let re=new DOMParser().parseFromString(y,"text/html");Q(y,o,ee(re,o),i)}):(p.status>=500?qe():Oe()).then(L=>{L?_e(L,o):location.href=o})).catch(p=>{(p==null?void 0:p.name)!=="AbortError"&&(Y(),location.href=o)}).finally(()=>{H&&!c.aborted&&(H=void 0)})}let ne=o=>{if(o.defaultPrevented||o.button!==0||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey)return;let i=o.target.closest("a[data-krate-link]");if(!i||!h(i))return;o.preventDefault();let s=i.getAttribute("href");if(!s)return;let c=new URL(s,location.origin).href,p=i.hasAttribute("data-krate-replace"),y=i.getAttribute("data-krate-scroll")!=="false";if(s===location.pathname+location.search+location.hash){p&&history.replaceState({},"",s),G(c,{scroll:y});return}te(c,{replace:p,scroll:y})},oe=()=>{te(location.href,{restoreScroll:!0})};document.addEventListener("click",ne),window.addEventListener("popstate",oe),S(),J(),document.querySelectorAll("script[src]").forEach(o=>{we.test(o.src)||o.setAttribute("data-krate-spa","")}),R=()=>{document.removeEventListener("click",ne),window.removeEventListener("popstate",oe),a()}}function ct(){R&&(R(),R=null),X=!1,ke()}return Fe(ft);})();
1
+ var __krate_exports=(()=>{var D=Object.defineProperty,Ve=Object.defineProperties,je=Object.getOwnPropertyDescriptor,Be=Object.getOwnPropertyDescriptors,Ke=Object.getOwnPropertyNames,me=Object.getOwnPropertySymbols;var ye=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable;var ge=(e,t,n)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ee=(e,t)=>{for(var n in t||(t={}))ye.call(t,n)&&ge(e,n,t[n]);if(me)for(var n of me(t))Ue.call(t,n)&&ge(e,n,t[n]);return e},Te=(e,t)=>Ve(e,Be(t));var We=(e,t)=>{for(var n in t)D(e,n,{get:t[n],enumerable:!0})},Fe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of Ke(t))!ye.call(e,c)&&c!==n&&D(e,c,{get:()=>t[c],enumerable:!(r=je(t,c))||r.enumerable});return e};var $e=e=>Fe(D({},"__esModule",{value:!0}),e);var dt={};We(dt,{clearNodes:()=>xe,conditional:()=>lt,createEffect:()=>k,createMemo:()=>Je,createResource:()=>st,createSignal:()=>C,disposeAll:()=>ze,disposeNode:()=>x,forwardRef:()=>et,h:()=>ot,hydrate:()=>it,initRouter:()=>Re,insert:()=>nt,mount:()=>rt,onCleanup:()=>X,onMount:()=>Qe,reconcile:()=>ct,reconcileTrees:()=>Z,reinitRouter:()=>ut,useRef:()=>Ze});var L=[],be=[],W=!1,H=new Set,F=[],$=[],I=!1;function Ne(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function z(e){if(!e.disposed){e.disposed=!0;for(let t of e.sources)t.delete(e);e.sources.clear();for(let t of e.cleanups)t();e.cleanups.length=0}}function ze(){for(let e of H)z(e);H.clear();for(let e of F)try{e()}catch(t){}F.length=0,$.length=0,I=!1}function C(e){let t=e,n=new Set;return[()=>{let a=L[L.length-1];return a&&!a.disposed&&(n.add(a),a.sources.add(n)),t},a=>{let u=typeof a=="function"?a(t):a;if(u!==t){t=u;let y=Array.from(n);for(let h of y){if(h.disposed){n.delete(h);continue}if(h.running){h.rerun=!0;continue}h.queued||(h.queued=!0,$.push(h))}Xe()}}]}function Xe(){I||(I=!0,queueMicrotask(Ye))}function Ye(){I=!1;let e=$.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,V(t),t.rerun&&!t.disposed&&(t.rerun=!1,V(t)))}function V(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,L.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{L.pop(),e.running=!1}}function k(e){let t=Ne(e);return H.add(t),V(t),()=>{z(t),H.delete(t)}}function X(e){let t=L[L.length-1];t?t.cleanups.push(e):F.push(e)}function Qe(e){be.push(e),W||(W=!0,queueMicrotask(Ge))}function Ge(){W=!1;let e=be.splice(0);for(let t of e)t()}function Je(e){let[t,n]=C(void 0),r=Ne(()=>{let a=e();n(a)});H.add(r),V(r);let c=L[L.length-1];return c&&c.cleanups.push(()=>{r.disposed||(z(r),H.delete(r))}),t}function Ze(e){return{current:e}}function et(e){return t=>e(t,t.ref||(()=>{}))}var Y=new WeakMap;function Se(e,t){let n=Y.get(e);n||(n=[],Y.set(e,n)),n.push(t)}function x(e){let t=Y.get(e);if(t){for(let n of t)n();t.length=0}for(let n=0;n<e.childNodes.length;n++)x(e.childNodes[n])}function tt(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function xe(e,t){let n=e.parentNode;if(!n)return;let r=e.nextSibling;for(;r&&r!==t;){let c=r.nextSibling;x(r),n.removeChild(r),r=c}}function nt(e,t,n){let r=tt(n);r?(xe(n,r),Q(e,t,r)):Q(e,t,null)}function Q(e,t,n){if(!(t==null||t===!1||t===!0)){if(typeof t=="string"||typeof t=="number")e.insertBefore(document.createTextNode(String(t)),n);else if(t instanceof Node)e.insertBefore(t,n);else if(Array.isArray(t))for(let r of t)Q(e,r,n)}}function ve(e,t,n){if(t==="class"||t==="className")n===!1||n===null||n===void 0?e.className="":e.className=String(n);else if(t==="style")typeof n=="string"?e.setAttribute("style",n):n&&typeof n=="object"&&Object.assign(e.style,n);else if(t.startsWith("on")&&typeof n=="function"){let r=t.slice(2).toLowerCase(),c=`__krate_${r}`,a=e[c];a&&e.removeEventListener(r,a),e.addEventListener(r,n),e[c]=n}else t==="ref"?typeof n=="function"?n(e):n&&typeof n=="object"&&"current"in n&&(n.current=e):t==="key"||n!=null&&n!==!1&&e.setAttribute(t,String(n))}function Ae(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)Ae(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),Se(n,k(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function ot(e,t,...n){if(typeof e=="function")return e(Te(Ee({},t||{}),{children:n}));let r=document.createElement(e);if(t)for(let[c,a]of Object.entries(t))typeof a=="function"&&!c.startsWith("on")?Se(r,k(()=>ve(r,c,a()))):ve(r,c,a);for(let c of n)Ae(r,c);return r}function ke(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function rt(e,t){let n=ke(t),r=!1;k(()=>{r||(r=!0,n.appendChild(e()))})}function it(e,t){let n=ke(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&x(r)}function st(e,t){let[n,r]=C(void 0),[c,a]=C(!0),[u,y]=C(void 0),[h,m]=C("unresolved"),[N,d]=C(0),l,g=()=>typeof e=="function"?e():e,T=async()=>{l&&l.abort(),l=new AbortController;let A=l,q=g();m(N()>0?"refreshing":"loading"),a(!0),y(void 0);try{let w=await t(q,{signal:A.signal});A.signal.aborted||(r(()=>w),m("ready"))}catch(w){(w==null?void 0:w.name)!=="AbortError"&&!A.signal.aborted&&(y(w),m("error"))}finally{A.signal.aborted||a(!1)}};k(()=>{typeof e=="function"&&e.length===0&&e(),N(),T(),X(()=>{l&&(l.abort(),l=void 0)})});let E=function(){return n()};return Object.defineProperties(E,{loading:{get:()=>c()},error:{get:()=>u()},state:{get:()=>h()}}),[E,{mutate:A=>{r(A)},refetch:()=>{d(A=>A+1)}}]}function ct(e,t,n,r,c,a){let u=[],y=t.nextSibling;for(;y&&y!==n;)u.push(y),y=y.nextSibling;if(a){let h=new Map;for(let d of u){let l=d.__k;l!=null&&h.set(l,d)}let m=[],N=new Set;for(let d=0;d<r.length;d++){let l=r[d],g=a(l);N.add(g);let T=c(l,d);T.__k=g,m.push(T)}for(let[d,l]of h)!N.has(d)&&l.parentNode===e&&(x(l),e.removeChild(l));for(let d=0;d<m.length;d++){let l=m[d],g=d===0?t:m[d-1];l!==g.nextSibling&&e.insertBefore(l,g.nextSibling)}}else{let h=Math.max(u.length,r.length);for(let m=0;m<h;m++)if(m<r.length){let N=c(r[m],m);m<u.length?u[m]!==N&&(x(u[m]),e.replaceChild(N,u[m])):e.insertBefore(N,n)}else m<u.length&&u[m].parentNode===e&&(x(u[m]),e.removeChild(u[m]))}}function lt(e,t,n,r,c,a){let u=null;k(()=>{let h=r()?c():a?a():null;u?h?(x(u),e.replaceChild(h,u)):(x(u),e.removeChild(u)):h&&e.insertBefore(h,n),u=h})}function P(e){if(e.nodeType===Node.COMMENT_NODE){let t=e.nodeValue||"";return t.indexOf("k:")===0?t:null}if(e.nodeType===Node.ELEMENT_NODE){let t=e,n=t.getAttribute("data-k");if(n)return n;let r=t.getAttribute("id");if(r)return"#"+r}return null}function we(e,t){let n=new Set;for(let r=0;r<t.attributes.length;r++){let c=t.attributes[r].name,a=t.attributes[r].value;n.add(c),e.getAttribute(c)!==a&&e.setAttribute(c,a)}for(let r=0;r<e.attributes.length;r++){let c=e.attributes[r].name;n.has(c)||e.removeAttribute(c)}}function G(e,t){let n=document.importNode(t,!0);return e.parentNode&&(x(e),e.parentNode.replaceChild(n,e)),n}function Le(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!0}function J(e,t){if(!Le(e,t))return G(e,t);if(e.nodeType===Node.TEXT_NODE)return e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e;if(e.nodeType===Node.COMMENT_NODE)return e.nodeValue!==t.nodeValue?G(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,r=t;return P(n)!==P(r)?G(n,r):(we(n,r),Ce(n,r),n)}function Ce(e,t){let n=Array.from(e.childNodes),r=Array.from(t.childNodes);if(n.length===r.length){let d=!0;for(let l=0;l<r.length;l++)if(P(n[l])!==P(r[l])){d=!1;break}if(d){for(let l=0;l<r.length;l++)J(n[l],r[l]);return}}let c=new Map,a=[];n.forEach((d,l)=>{let g=P(d);g!=null?c.has(g)||c.set(g,l):a.push(l)});let u=new Set,y=0,h=null,m=0,N=()=>{for(;m<a.length&&u.has(a[m]);)m++;return m<a.length?a[m]:-1};for(let d of r){let l=P(d),g;if(l!=null&&c.has(l)){let T=c.get(l);c.delete(l),u.add(T);let E=n[T];T<y?e.insertBefore(E,h):y=T,g=J(E,d)}else if(l==null){let T=N();if(T>=0&&Le(n[T],d)){u.add(T);let E=n[T];E.parentNode===e&&E.nextSibling!==h&&e.insertBefore(E,h),g=J(E,d)}else g=document.importNode(d,!0),e.insertBefore(g,h)}else g=document.importNode(d,!0),e.insertBefore(g,h);h=g.nextSibling}n.forEach((d,l)=>{!u.has(l)&&d.parentNode===e&&(x(d),e.removeChild(d))})}function Z(e,t){if(e.nodeType!==Node.ELEMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return;let n=e,r=t;if(n.tagName!==r.tagName){let c=document.importNode(t,!0);n.parentNode&&n.parentNode.replaceChild(c,n);return}we(n,r),Ce(n,r)}var ee=!1,_,j=null,M=new Map,ft=30,O=new Map,at=50,Me=/\/chunks\/runtime\.[^/]+\.js$/;function Re(){if(typeof document=="undefined"||ee)return;ee=!0;let e=".docs-content, main, #root",t=150,n=200,r=null,c=null,a=new Map,u=null;function y(o){for(let i of e.split(", ")){let s=o.querySelector(i.trim());if(s)return s}return o.body}function h(o){if(o.hasAttribute("data-krate-external"))return!1;let i=o.getAttribute("href");return!(!i||i.startsWith("#")||i.startsWith("javascript:")||o.origin!==location.origin||o.target==="_blank")}function m(o){M.has(o)||fetch(o,{headers:{Accept:"text/html"}}).then(i=>i.ok?i.text():null).then(i=>{if(i){if(M.size>=ft){let s=M.keys().next().value;s!==void 0&&M.delete(s)}M.set(o,i)}}).catch(()=>{})}function N(){document.addEventListener("mouseover",g),document.addEventListener("focusin",g),typeof IntersectionObserver!="undefined"&&(u=new IntersectionObserver(o=>{for(let i of o)if(i.isIntersecting){let s=i.target,f=s.getAttribute("href");if(f&&h(s)){let p=new URL(f,location.origin).href;m(p)}u.unobserve(i.target)}},{rootMargin:"200px"}),d())}function d(){u&&document.querySelectorAll("a[data-prefetch]").forEach(o=>{u.observe(o)})}function l(){document.removeEventListener("mouseover",g),document.removeEventListener("focusin",g);for(let o of a.values())clearTimeout(o);a.clear(),u&&(u.disconnect(),u=null)}function g(o){let i=o.target.closest("a[data-prefetch]");if(!i||!h(i))return;let s=i.getAttribute("href");if(!s)return;let f=new URL(s,location.origin).href;if(M.has(f))return;let p=a.get(i);p&&clearTimeout(p);let b=setTimeout(()=>{a.delete(i),m(f)},n);a.set(i,b)}function T(o){let i=document.createTreeWalker(o,NodeFilter.SHOW_ELEMENT),s=i.nextNode();for(;s;){let f=s;for(let p of Object.keys(f))p.indexOf("__krate_")===0&&delete f[p];s=i.nextNode()}}let E=null;function te(){let o=y(document),i=document.querySelector("template[data-krate-loading]");i&&i.content&&o&&(E=i.content.cloneNode(!0),document.body.appendChild(E)),o&&(o.style.transition=`opacity ${t}ms ease`,o.style.opacity="0")}function A(){E&&E.parentNode&&E.parentNode.removeChild(E),E=null;let o=y(document);o&&(o.style.opacity="1")}function q(o,i,s,f={}){let{replace:p=!1,scroll:b=!0,restoreScroll:R=!1}=f,B=new DOMParser().parseFromString(o,"text/html"),ae=y(B),K=y(document);if(!ae||!K){location.href=i;return}let ue=B.querySelector("title");ue&&(document.title=ue.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),T(K),Z(K,ae);let de=B.querySelectorAll('link[rel="stylesheet"]'),pe=new Set;de.forEach(v=>{let S=v.getAttribute("href");S&&pe.add(S)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(v=>{let S=v.getAttribute("href");S&&!pe.has(S)&&v.remove()});let he=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(v=>{he.add(v.href)}),de.forEach(v=>{let S=v.getAttribute("href");if(S&&!he.has(S)){let U=document.createElement("link");U.rel="stylesheet",U.href=S,document.head.appendChild(U)}}),He(s,i).then(()=>{try{_e(),d()}catch(v){try{let S=globalThis.__krate_onHydrationError;typeof S=="function"&&S(v)}catch(S){}location.href=i}}),A();let Ie=location.pathname+location.search;if(p)history.replaceState({},"",i);else{if(!R){if(O.size>=at){let v=O.keys().next().value;v!==void 0&&O.delete(v)}O.set(Ie,window.scrollY)}history.pushState({},"",i)}ne(i,{restoreScroll:R,scroll:b}),oe(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:i}}))}function w(o){let i=o.indexOf("#");if(i<0||i===o.length-1)return!1;let s=o.slice(i);try{let f=document.querySelector(s);if(f)return f.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch(f){return!1}return!1}function ne(o,i){if(i.restoreScroll){let s=O.get(o);if(s!==void 0){window.scrollTo(0,s);return}}w(o)||i.scroll&&window.scrollTo(0,0)}function oe(){let o=location.pathname;document.querySelectorAll("a[data-krate-link]").forEach(i=>{let s=i.getAttribute("href");if(!s){i.removeAttribute("aria-current");return}let f=s;try{f=new URL(s,location.origin).pathname}catch(b){return}f===o||o==="/"&&(f===""||f==="/")||f!=="/"&&f.length>1&&o.startsWith(f)?i.setAttribute("aria-current","page"):i.removeAttribute("aria-current")})}function He(o,i){return o.length===0?Promise.resolve():Promise.all(o.map(s=>{let f=s.getAttribute("src");return f?Pe(f,i):Promise.resolve()})).then(()=>{})}function Pe(o,i){return new Promise(s=>{let f=document.createElement("script"),p=re(o,i);f.src=p,Me.test(p)||f.setAttribute("data-krate-spa",""),f.onload=()=>s(),f.onerror=()=>s(),document.body.appendChild(f)})}function re(o,i){if(/^(https?:)?\/\//.test(o)||o.startsWith("/"))return new URL(o,i).href;let s=i;if(!s.endsWith("/")){let f=s.lastIndexOf("/");s=f>0?s.slice(0,f+1):"/"}return new URL(o,s).href}function _e(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function Oe(o,i){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",i),document.open(),document.write(o),document.close()}function qe(){return r!==null?Promise.resolve(r):fetch("/404.html",{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>(r=o,o)).catch(()=>null)}function De(){return c!==null?Promise.resolve(c):fetch("/500.html",{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>(c=o,o)).catch(()=>null)}function ie(o,i){document.querySelectorAll("script[data-krate-spa]").forEach(p=>p.remove());let s=[],f=new Set;return document.querySelectorAll("script[src]").forEach(p=>{f.add(p.src)}),o.querySelectorAll("script[src]").forEach(p=>{let b=p.getAttribute("src");b&&!f.has(re(b,i))&&s.push(p)}),s}function se(o,i={}){let s=M.get(o);if(s){let b=new DOMParser().parseFromString(s,"text/html");q(s,o,ie(b,o),i);return}te(),_&&_.abort(),_=new AbortController;let f=_.signal;fetch(o,{headers:{Accept:"text/html"},signal:f}).then(p=>p.ok?p.text().then(b=>{let fe=new DOMParser().parseFromString(b,"text/html");q(b,o,ie(fe,o),i)}):(p.status>=500?De():qe()).then(R=>{R?Oe(R,o):location.href=o})).catch(p=>{(p==null?void 0:p.name)!=="AbortError"&&(A(),location.href=o)}).finally(()=>{_&&!f.aborted&&(_=void 0)})}let ce=o=>{if(o.defaultPrevented||o.button!==0||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey)return;let i=o.target.closest("a[data-krate-link]");if(!i||!h(i))return;o.preventDefault();let s=i.getAttribute("href");if(!s)return;let f=new URL(s,location.origin).href,p=i.hasAttribute("data-krate-replace"),b=i.getAttribute("data-krate-scroll")!=="false";if(s===location.pathname+location.search+location.hash){p&&history.replaceState({},"",s),ne(f,{scroll:b});return}se(f,{replace:p,scroll:b})},le=()=>{se(location.href,{restoreScroll:!0})};document.addEventListener("click",ce),window.addEventListener("popstate",le),N(),oe(),document.querySelectorAll("script[src]").forEach(o=>{Me.test(o.src)||o.setAttribute("data-krate-spa","")}),j=()=>{document.removeEventListener("click",ce),window.removeEventListener("popstate",le),l()}}function ut(){j&&(j(),j=null),ee=!1,Re()}return $e(dt);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
@@ -1,2 +1,2 @@
1
- var __krate_exports=(()=>{var D=Object.defineProperty,Ve=Object.defineProperties,Ue=Object.getOwnPropertyDescriptor,ze=Object.getOwnPropertyDescriptors,Ke=Object.getOwnPropertyNames,O=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var be=(e,t,n)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fe=(e,t)=>{for(var n in t||(t={}))U.call(t,n)&&be(e,n,t[n]);if(O)for(var n of O(t))me.call(t,n)&&be(e,n,t[n]);return e},pe=(e,t)=>Ve(e,ze(t));var he=(e,t)=>{var n={};for(var r in e)U.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&O)for(var r of O(e))t.indexOf(r)<0&&me.call(e,r)&&(n[r]=e[r]);return n};var We=(e,t)=>{for(var n in t)D(e,n,{get:t[n],enumerable:!0})},Xe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ke(t))!U.call(e,o)&&o!==n&&D(e,o,{get:()=>t[o],enumerable:!(r=Ue(t,o))||r.enumerable});return e};var je=e=>Xe(D({},"__esModule",{value:!0}),e);var bt={};We(bt,{Fragment:()=>ot,clearNodes:()=>Me,conditional:()=>lt,createEffect:()=>x,createMemo:()=>et,createSignal:()=>He,disposeAll:()=>Ge,disposeNode:()=>E,forwardRef:()=>tt,h:()=>_,hydrate:()=>st,initRouter:()=>Ce,insert:()=>rt,jsx:()=>xe,jsxs:()=>at,mount:()=>it,onCleanup:()=>$e,onMount:()=>Qe,reconcile:()=>ut,reconcileTrees:()=>Y,reinitRouter:()=>gt});var y=[],Te=[],z=!1,w=new Set,K=[],I=!1;function ve(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function W(e){if(!e.disposed){e.disposed=!0;for(let t of e.sources)t.delete(e);e.sources.clear();for(let t of e.cleanups)t();e.cleanups.length=0}}function Ge(){for(let e of w)W(e);w.clear(),K.length=0,I=!1}function He(e){let t=e,n=new Set;return[()=>{let l=y[y.length-1];return l&&!l.disposed&&(n.add(l),l.sources.add(n)),t},l=>{let c=typeof l=="function"?l(t):l;if(c!==t){t=c;let h=Array.from(n);for(let m of h){if(m.disposed){n.delete(m);continue}if(m.running){m.rerun=!0;continue}m.queued||(m.queued=!0,K.push(m))}Je()}}]}function Je(){I||(I=!0,queueMicrotask(Ye))}function Ye(){I=!1;let e=K.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,B(t),t.rerun&&!t.disposed&&(t.rerun=!1,B(t)))}function B(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,y.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{y.pop(),e.running=!1}}function x(e){let t=ve(e);return w.add(t),B(t),()=>{W(t),w.delete(t)}}function $e(e){let t=y[y.length-1];t&&t.cleanups.push(e)}function Qe(e){Te.push(e),z||(z=!0,queueMicrotask(Ze))}function Ze(){z=!1;let e=Te.splice(0);for(let t of e)t()}function et(e){let[t,n]=He(void 0),r=ve(()=>{let l=e();n(l)});w.add(r),B(r);let o=y[y.length-1];return o&&o.cleanups.push(()=>{r.disposed||(W(r),w.delete(r))}),t}function tt(e){return t=>e(t,t.ref||(()=>{}))}var X=new WeakMap;function Ae(e,t){let n=X.get(e);n||(n=[],X.set(e,n)),n.push(t)}function E(e){let t=X.get(e);if(t){for(let n of t)n();t.length=0}for(let n=0;n<e.childNodes.length;n++)E(e.childNodes[n])}function nt(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function Me(e,t){let n=e.parentNode;if(!n)return;let r=e.nextSibling;for(;r&&r!==t;){let o=r.nextSibling;E(r),n.removeChild(r),r=o}}function rt(e,t,n){let r=nt(n);r?(Me(n,r),j(e,t,r)):j(e,t,null)}function j(e,t,n){if(!(t==null||t===!1||t===!0)){if(typeof t=="string"||typeof t=="number")e.insertBefore(document.createTextNode(String(t)),n);else if(t instanceof Node)e.insertBefore(t,n);else if(Array.isArray(t))for(let r of t)j(e,r,n)}}function Ee(e,t,n){if(t==="class"||t==="className")n===!1||n===null||n===void 0?e.className="":e.className=String(n);else if(t==="style")typeof n=="string"?e.setAttribute("style",n):n&&typeof n=="object"&&Object.assign(e.style,n);else if(t.startsWith("on")&&typeof n=="function"){let r=t.slice(2).toLowerCase(),o=`__krate_${r}`,l=e[o];l&&e.removeEventListener(r,l),e.addEventListener(r,n),e[o]=n}else t==="ref"?typeof n=="function"&&n(e):t==="key"||n!=null&&n!==!1&&e.setAttribute(t,String(n))}function Le(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)Le(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),Ae(n,x(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function _(e,t,...n){if(typeof e=="function")return e(pe(fe({},t||{}),{children:n}));let r=document.createElement(e);if(t)for(let[o,l]of Object.entries(t))typeof l=="function"&&!o.startsWith("on")?Ae(r,x(()=>Ee(r,o,l()))):Ee(r,o,l);for(let o of n)Le(r,o);return r}function ye(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function it(e,t){let n=ye(t),r=!1;x(()=>{r||(r=!0,n.appendChild(e()))})}function st(e,t){let n=ye(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&E(r)}function ot(e){let t=document.createDocumentFragment(),n=e.children;if(n){let r=Array.isArray(n)?n:[n];for(let o of r)o instanceof Node?t.appendChild(o):t.appendChild(document.createTextNode(String(o)))}return t}function xe(e,t,n){let r=e;if(!t)return _(r,null);let h=t,{children:o}=h,l=he(h,["children"]),c=o!==void 0?Array.isArray(o)?o:[o]:[];return _(r,Object.keys(l).length>0?l:null,...c)}function at(e,t,n){return xe(e,t,n)}function ut(e,t,n,r,o,l){let c=[],h=t.nextSibling;for(;h&&h!==n;)c.push(h),h=h.nextSibling;if(l){let m=new Map;for(let g of c){let d=g.__k;d!=null&&m.set(d,g)}let f=[],M=new Set;for(let g=0;g<r.length;g++){let d=r[g],p=l(d);M.add(p);let H=o(d,g);H.__k=p,f.push(H)}for(let[g,d]of m)!M.has(g)&&d.parentNode===e&&(E(d),e.removeChild(d));for(let g=0;g<f.length;g++){let d=f[g],p=g===0?t:f[g-1];d!==p.nextSibling&&e.insertBefore(d,p.nextSibling)}}else{let m=Math.max(c.length,r.length);for(let f=0;f<m;f++)if(f<r.length){let M=o(r[f],f);f<c.length?c[f]!==M&&(E(c[f]),e.replaceChild(M,c[f])):e.insertBefore(M,n)}else f<c.length&&c[f].parentNode===e&&(E(c[f]),e.removeChild(c[f]))}}function lt(e,t,n,r,o,l){let c=null;x(()=>{let m=r()?o():l?l():null;c?m?(E(c),e.replaceChild(m,c)):(E(c),e.removeChild(c)):m&&e.insertBefore(m,n),c=m})}function N(e){if(e.nodeType===Node.COMMENT_NODE){let t=e.nodeValue||"";return t.indexOf("k:")===0?t:null}if(e.nodeType===Node.ELEMENT_NODE){let t=e,n=t.getAttribute("data-k");if(n)return n;let r=t.getAttribute("id");if(r)return"#"+r}return null}function Se(e,t){let n=new Set;for(let r=0;r<t.attributes.length;r++){let o=t.attributes[r].name,l=t.attributes[r].value;n.add(o),e.getAttribute(o)!==l&&e.setAttribute(o,l)}for(let r=0;r<e.attributes.length;r++){let o=e.attributes[r].name;n.has(o)||e.removeAttribute(o)}}function G(e,t){let n=document.importNode(t,!0);return e.parentNode&&(E(e),e.parentNode.replaceChild(n,e)),n}function ke(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!0}function J(e,t){if(!ke(e,t))return G(e,t);if(e.nodeType===Node.TEXT_NODE)return e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e;if(e.nodeType===Node.COMMENT_NODE)return e.nodeValue!==t.nodeValue?G(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,r=t;return N(n)!==N(r)?G(n,r):(Se(n,r),we(n,r),n)}function we(e,t){let n=Array.from(e.childNodes),r=Array.from(t.childNodes);if(n.length===r.length){let g=!0;for(let d=0;d<r.length;d++)if(N(n[d])!==N(r[d])){g=!1;break}if(g){for(let d=0;d<r.length;d++)J(n[d],r[d]);return}}let o=new Map,l=[];n.forEach((g,d)=>{let p=N(g);p!=null?o.has(p)||o.set(p,d):l.push(d)});let c=new Set,h=0,m=null,f=0,M=()=>{for(;f<l.length&&c.has(l[f]);)f++;return f<l.length?l[f]:-1};for(let g of r){let d=N(g),p;if(d!=null&&o.has(d)){let H=o.get(d);o.delete(d),c.add(H);let v=n[H];H<h?e.insertBefore(v,m):h=H,p=J(v,g)}else if(d==null){let H=M();if(H>=0&&ke(n[H],g)){c.add(H);let v=n[H];v.parentNode===e&&v.nextSibling!==m&&e.insertBefore(v,m),p=J(v,g)}else p=document.importNode(g,!0),e.insertBefore(p,m)}else p=document.importNode(g,!0),e.insertBefore(p,m);m=p.nextSibling}n.forEach((g,d)=>{!c.has(d)&&g.parentNode===e&&(E(g),e.removeChild(g))})}function Y(e,t){if(e.nodeType!==Node.ELEMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return;let n=e,r=t;if(n.tagName!==r.tagName){let o=document.importNode(t,!0);n.parentNode&&n.parentNode.replaceChild(o,n);return}Se(n,r),we(n,r)}var $=!1,C,R=null,S=new Map,ct=30,P=new Map,dt=50,Ne=/\/chunks\/runtime\.[^/]+\.js$/;function Ce(){if(typeof document=="undefined"||$)return;$=!0;let e=".docs-content, main, #root",t=150,n=200,r=null,o=null,l=new Map,c=null;function h(i){for(let s of e.split(", ")){let a=i.querySelector(s.trim());if(a)return a}return i.body}function m(i){if(i.hasAttribute("data-krate-external"))return!1;let s=i.getAttribute("href");return!(!s||s.startsWith("#")||s.startsWith("javascript:")||i.origin!==location.origin||i.target==="_blank")}function f(i){S.has(i)||fetch(i,{headers:{Accept:"text/html"}}).then(s=>s.ok?s.text():null).then(s=>{if(s){if(S.size>=ct){let a=S.keys().next().value;a!==void 0&&S.delete(a)}S.set(i,s)}}).catch(()=>{})}function M(){document.addEventListener("mouseover",p),document.addEventListener("focusin",p),typeof IntersectionObserver!="undefined"&&(c=new IntersectionObserver(i=>{for(let s of i)if(s.isIntersecting){let a=s.target,u=a.getAttribute("href");if(u&&m(a)){let b=new URL(u,location.origin).href;f(b)}c.unobserve(s.target)}},{rootMargin:"200px"}),g())}function g(){c&&document.querySelectorAll("a[data-prefetch]").forEach(i=>{c.observe(i)})}function d(){document.removeEventListener("mouseover",p),document.removeEventListener("focusin",p);for(let i of l.values())clearTimeout(i);l.clear(),c&&(c.disconnect(),c=null)}function p(i){let s=i.target.closest("a[data-prefetch]");if(!s||!m(s))return;let a=s.getAttribute("href");if(!a)return;let u=new URL(a,location.origin).href;if(S.has(u))return;let b=l.get(s);b&&clearTimeout(b);let T=setTimeout(()=>{l.delete(s),f(u)},n);l.set(s,T)}function H(i){let s=document.createTreeWalker(i,NodeFilter.SHOW_ELEMENT),a=s.nextNode();for(;a;){let u=a;for(let b of Object.keys(u))b.indexOf("__krate_")===0&&delete u[b];a=s.nextNode()}}let v=null;function Pe(){let i=h(document),s=document.querySelector("template[data-krate-loading]");s&&s.content&&i&&(v=s.content.cloneNode(!0),document.body.appendChild(v)),i&&(i.style.transition=`opacity ${t}ms ease`,i.style.opacity="0")}function Q(){v&&v.parentNode&&v.parentNode.removeChild(v),v=null;let i=h(document);i&&(i.style.opacity="1")}function Z(i,s,a,u={}){let{replace:b=!1,scroll:T=!0,restoreScroll:k=!1}=u,q=new DOMParser().parseFromString(i,"text/html"),ue=h(q),F=h(document);if(!ue||!F){location.href=s;return}let le=q.querySelector("title");le&&(document.title=le.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),H(F),Y(F,ue);let ce=q.querySelectorAll('link[rel="stylesheet"]'),de=new Set;ce.forEach(A=>{let L=A.getAttribute("href");L&&de.add(L)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(A=>{let L=A.getAttribute("href");L&&!de.has(L)&&A.remove()});let ge=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(A=>{ge.add(A.href)}),ce.forEach(A=>{let L=A.getAttribute("href");if(L&&!ge.has(L)){let V=document.createElement("link");V.rel="stylesheet",V.href=L,document.head.appendChild(V)}}),De(a,s).then(()=>{Be(),g()}),Q();let Fe=location.pathname+location.search;if(b)history.replaceState({},"",s);else{if(!k){if(P.size>=dt){let A=P.keys().next().value;A!==void 0&&P.delete(A)}P.set(Fe,window.scrollY)}history.pushState({},"",s)}ee(s,{restoreScroll:k,scroll:T}),te(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:s}}))}function Oe(i){let s=i.indexOf("#");if(s<0||s===i.length-1)return!1;let a=i.slice(s);try{let u=document.querySelector(a);if(u)return u.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch(u){return!1}return!1}function ee(i,s){if(s.restoreScroll){let a=P.get(i);if(a!==void 0){window.scrollTo(0,a);return}}Oe(i)||s.scroll&&window.scrollTo(0,0)}function te(){let i=location.pathname;document.querySelectorAll("a[data-krate-link]").forEach(s=>{let a=s.getAttribute("href");if(!a){s.removeAttribute("aria-current");return}let u=a;try{u=new URL(a,location.origin).pathname}catch(T){return}u===i||i==="/"&&(u===""||u==="/")||u!=="/"&&u.length>1&&i.startsWith(u)?s.setAttribute("aria-current","page"):s.removeAttribute("aria-current")})}function De(i,s){return i.length===0?Promise.resolve():Promise.all(i.map(a=>{let u=a.getAttribute("src");return u?Ie(u,s):Promise.resolve()})).then(()=>{})}function Ie(i,s){return new Promise(a=>{let u=document.createElement("script"),b=ne(i,s);u.src=b,Ne.test(b)||u.setAttribute("data-krate-spa",""),u.onload=()=>a(),u.onerror=()=>a(),document.body.appendChild(u)})}function ne(i,s){if(/^(https?:)?\/\//.test(i)||i.startsWith("/"))return new URL(i,s).href;let a=s;if(!a.endsWith("/")){let u=a.lastIndexOf("/");a=u>0?a.slice(0,u+1):"/"}return new URL(i,a).href}function Be(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function _e(i,s){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",s),document.open(),document.write(i),document.close()}function Re(){return r!==null?Promise.resolve(r):fetch("/404.html",{headers:{Accept:"text/html"}}).then(i=>i.ok?i.text():null).then(i=>(r=i,i)).catch(()=>null)}function qe(){return o!==null?Promise.resolve(o):fetch("/500.html",{headers:{Accept:"text/html"}}).then(i=>i.ok?i.text():null).then(i=>(o=i,i)).catch(()=>null)}function re(i,s){document.querySelectorAll("script[data-krate-spa]").forEach(b=>b.remove());let a=[],u=new Set;return document.querySelectorAll("script[src]").forEach(b=>{u.add(b.src)}),i.querySelectorAll("script[src]").forEach(b=>{let T=b.getAttribute("src");T&&!u.has(ne(T,s))&&a.push(b)}),a}function ie(i,s={}){let a=S.get(i);if(a){let T=new DOMParser().parseFromString(a,"text/html");Z(a,i,re(T,i),s);return}Pe(),C&&C.abort(),C=new AbortController;let u=C.signal;fetch(i,{headers:{Accept:"text/html"},signal:u}).then(b=>b.ok?b.text().then(T=>{let ae=new DOMParser().parseFromString(T,"text/html");Z(T,i,re(ae,i),s)}):(b.status>=500?qe():Re()).then(k=>{k?_e(k,i):location.href=i})).catch(b=>{(b==null?void 0:b.name)!=="AbortError"&&(Q(),location.href=i)}).finally(()=>{C&&!u.aborted&&(C=void 0)})}let se=i=>{if(i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey)return;let s=i.target.closest("a[data-krate-link]");if(!s||!m(s))return;i.preventDefault();let a=s.getAttribute("href");if(!a)return;let u=new URL(a,location.origin).href,b=s.hasAttribute("data-krate-replace"),T=s.getAttribute("data-krate-scroll")!=="false";if(a===location.pathname+location.search+location.hash){b&&history.replaceState({},"",a),ee(u,{scroll:T});return}ie(u,{replace:b,scroll:T})},oe=()=>{ie(location.href,{restoreScroll:!0})};document.addEventListener("click",se),window.addEventListener("popstate",oe),M(),te(),document.querySelectorAll("script[src]").forEach(i=>{Ne.test(i.src)||i.setAttribute("data-krate-spa","")}),R=()=>{document.removeEventListener("click",se),window.removeEventListener("popstate",oe),d()}}function gt(){R&&(R(),R=null),$=!1,Ce()}return je(bt);})();
1
+ var __krate_exports=(()=>{var _=Object.defineProperty,ze=Object.defineProperties,je=Object.getOwnPropertyDescriptor,Ke=Object.getOwnPropertyDescriptors,We=Object.getOwnPropertyNames,B=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var Te=(e,t,n)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ee=(e,t)=>{for(var n in t||(t={}))W.call(t,n)&&Te(e,n,t[n]);if(B)for(var n of B(t))ve.call(t,n)&&Te(e,n,t[n]);return e},He=(e,t)=>ze(e,Ke(t));var Ae=(e,t)=>{var n={};for(var r in e)W.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&B)for(var r of B(e))t.indexOf(r)<0&&ve.call(e,r)&&(n[r]=e[r]);return n};var Xe=(e,t)=>{for(var n in t)_(e,n,{get:t[n],enumerable:!0})},Ge=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of We(t))!W.call(e,o)&&o!==n&&_(e,o,{get:()=>t[o],enumerable:!(r=je(t,o))||r.enumerable});return e};var Je=e=>Ge(_({},"__esModule",{value:!0}),e);var pt={};Xe(pt,{Fragment:()=>lt,clearNodes:()=>Se,conditional:()=>gt,createEffect:()=>x,createMemo:()=>tt,createResource:()=>ut,createSignal:()=>w,disposeAll:()=>Ye,disposeNode:()=>L,forwardRef:()=>rt,h:()=>V,hydrate:()=>at,initRouter:()=>De,insert:()=>st,jsx:()=>Ce,jsxs:()=>ct,mount:()=>ot,onCleanup:()=>$,onMount:()=>Ze,reconcile:()=>dt,reconcileTrees:()=>ne,reinitRouter:()=>mt,useRef:()=>nt});var k=[],Me=[],X=!1,P=new Set,G=[],J=[],q=!1;function Le(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function Y(e){if(!e.disposed){e.disposed=!0;for(let t of e.sources)t.delete(e);e.sources.clear();for(let t of e.cleanups)t();e.cleanups.length=0}}function Ye(){for(let e of P)Y(e);P.clear();for(let e of G)try{e()}catch(t){}G.length=0,J.length=0,q=!1}function w(e){let t=e,n=new Set;return[()=>{let u=k[k.length-1];return u&&!u.disposed&&(n.add(u),u.sources.add(n)),t},u=>{let d=typeof u=="function"?u(t):u;if(d!==t){t=d;let h=Array.from(n);for(let f of h){if(f.disposed){n.delete(f);continue}if(f.running){f.rerun=!0;continue}f.queued||(f.queued=!0,J.push(f))}$e()}}]}function $e(){q||(q=!0,queueMicrotask(Qe))}function Qe(){q=!1;let e=J.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,F(t),t.rerun&&!t.disposed&&(t.rerun=!1,F(t)))}function F(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,k.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{k.pop(),e.running=!1}}function x(e){let t=Le(e);return P.add(t),F(t),()=>{Y(t),P.delete(t)}}function $(e){let t=k[k.length-1];t?t.cleanups.push(e):G.push(e)}function Ze(e){Me.push(e),X||(X=!0,queueMicrotask(et))}function et(){X=!1;let e=Me.splice(0);for(let t of e)t()}function tt(e){let[t,n]=w(void 0),r=Le(()=>{let u=e();n(u)});P.add(r),F(r);let o=k[k.length-1];return o&&o.cleanups.push(()=>{r.disposed||(Y(r),P.delete(r))}),t}function nt(e){return{current:e}}function rt(e){return t=>e(t,t.ref||(()=>{}))}var Q=new WeakMap;function xe(e,t){let n=Q.get(e);n||(n=[],Q.set(e,n)),n.push(t)}function L(e){let t=Q.get(e);if(t){for(let n of t)n();t.length=0}for(let n=0;n<e.childNodes.length;n++)L(e.childNodes[n])}function it(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function Se(e,t){let n=e.parentNode;if(!n)return;let r=e.nextSibling;for(;r&&r!==t;){let o=r.nextSibling;L(r),n.removeChild(r),r=o}}function st(e,t,n){let r=it(n);r?(Se(n,r),Z(e,t,r)):Z(e,t,null)}function Z(e,t,n){if(!(t==null||t===!1||t===!0)){if(typeof t=="string"||typeof t=="number")e.insertBefore(document.createTextNode(String(t)),n);else if(t instanceof Node)e.insertBefore(t,n);else if(Array.isArray(t))for(let r of t)Z(e,r,n)}}function ye(e,t,n){if(t==="class"||t==="className")n===!1||n===null||n===void 0?e.className="":e.className=String(n);else if(t==="style")typeof n=="string"?e.setAttribute("style",n):n&&typeof n=="object"&&Object.assign(e.style,n);else if(t.startsWith("on")&&typeof n=="function"){let r=t.slice(2).toLowerCase(),o=`__krate_${r}`,u=e[o];u&&e.removeEventListener(r,u),e.addEventListener(r,n),e[o]=n}else t==="ref"?typeof n=="function"?n(e):n&&typeof n=="object"&&"current"in n&&(n.current=e):t==="key"||n!=null&&n!==!1&&e.setAttribute(t,String(n))}function ke(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)ke(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),xe(n,x(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function V(e,t,...n){if(typeof e=="function")return e(He(Ee({},t||{}),{children:n}));let r=document.createElement(e);if(t)for(let[o,u]of Object.entries(t))typeof u=="function"&&!o.startsWith("on")?xe(r,x(()=>ye(r,o,u()))):ye(r,o,u);for(let o of n)ke(r,o);return r}function we(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function ot(e,t){let n=we(t),r=!1;x(()=>{r||(r=!0,n.appendChild(e()))})}function at(e,t){let n=we(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&L(r)}function ut(e,t){let[n,r]=w(void 0),[o,u]=w(!0),[d,h]=w(void 0),[f,m]=w("unresolved"),[H,g]=w(0),l,p=()=>typeof e=="function"?e():e,v=async()=>{l&&l.abort(),l=new AbortController;let y=l,I=p();m(H()>0?"refreshing":"loading"),u(!0),h(void 0);try{let S=await t(I,{signal:y.signal});y.signal.aborted||(r(()=>S),m("ready"))}catch(S){(S==null?void 0:S.name)!=="AbortError"&&!y.signal.aborted&&(h(S),m("error"))}finally{y.signal.aborted||u(!1)}};x(()=>{typeof e=="function"&&e.length===0&&e(),H(),v(),$(()=>{l&&(l.abort(),l=void 0)})});let T=function(){return n()};return Object.defineProperties(T,{loading:{get:()=>o()},error:{get:()=>d()},state:{get:()=>f()}}),[T,{mutate:y=>{r(y)},refetch:()=>{g(y=>y+1)}}]}function lt(e){let t=document.createDocumentFragment(),n=e.children;if(n){let r=Array.isArray(n)?n:[n];for(let o of r)o instanceof Node?t.appendChild(o):t.appendChild(document.createTextNode(String(o)))}return t}function Ce(e,t,n){let r=e;if(!t)return V(r,null);let h=t,{children:o}=h,u=Ae(h,["children"]),d=o!==void 0?Array.isArray(o)?o:[o]:[];return V(r,Object.keys(u).length>0?u:null,...d)}function ct(e,t,n){return Ce(e,t,n)}function dt(e,t,n,r,o,u){let d=[],h=t.nextSibling;for(;h&&h!==n;)d.push(h),h=h.nextSibling;if(u){let f=new Map;for(let g of d){let l=g.__k;l!=null&&f.set(l,g)}let m=[],H=new Set;for(let g=0;g<r.length;g++){let l=r[g],p=u(l);H.add(p);let v=o(l,g);v.__k=p,m.push(v)}for(let[g,l]of f)!H.has(g)&&l.parentNode===e&&(L(l),e.removeChild(l));for(let g=0;g<m.length;g++){let l=m[g],p=g===0?t:m[g-1];l!==p.nextSibling&&e.insertBefore(l,p.nextSibling)}}else{let f=Math.max(d.length,r.length);for(let m=0;m<f;m++)if(m<r.length){let H=o(r[m],m);m<d.length?d[m]!==H&&(L(d[m]),e.replaceChild(H,d[m])):e.insertBefore(H,n)}else m<d.length&&d[m].parentNode===e&&(L(d[m]),e.removeChild(d[m]))}}function gt(e,t,n,r,o,u){let d=null;x(()=>{let f=r()?o():u?u():null;d?f?(L(d),e.replaceChild(f,d)):(L(d),e.removeChild(d)):f&&e.insertBefore(f,n),d=f})}function O(e){if(e.nodeType===Node.COMMENT_NODE){let t=e.nodeValue||"";return t.indexOf("k:")===0?t:null}if(e.nodeType===Node.ELEMENT_NODE){let t=e,n=t.getAttribute("data-k");if(n)return n;let r=t.getAttribute("id");if(r)return"#"+r}return null}function Ne(e,t){let n=new Set;for(let r=0;r<t.attributes.length;r++){let o=t.attributes[r].name,u=t.attributes[r].value;n.add(o),e.getAttribute(o)!==u&&e.setAttribute(o,u)}for(let r=0;r<e.attributes.length;r++){let o=e.attributes[r].name;n.has(o)||e.removeAttribute(o)}}function ee(e,t){let n=document.importNode(t,!0);return e.parentNode&&(L(e),e.parentNode.replaceChild(n,e)),n}function Pe(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!0}function te(e,t){if(!Pe(e,t))return ee(e,t);if(e.nodeType===Node.TEXT_NODE)return e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e;if(e.nodeType===Node.COMMENT_NODE)return e.nodeValue!==t.nodeValue?ee(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,r=t;return O(n)!==O(r)?ee(n,r):(Ne(n,r),Oe(n,r),n)}function Oe(e,t){let n=Array.from(e.childNodes),r=Array.from(t.childNodes);if(n.length===r.length){let g=!0;for(let l=0;l<r.length;l++)if(O(n[l])!==O(r[l])){g=!1;break}if(g){for(let l=0;l<r.length;l++)te(n[l],r[l]);return}}let o=new Map,u=[];n.forEach((g,l)=>{let p=O(g);p!=null?o.has(p)||o.set(p,l):u.push(l)});let d=new Set,h=0,f=null,m=0,H=()=>{for(;m<u.length&&d.has(u[m]);)m++;return m<u.length?u[m]:-1};for(let g of r){let l=O(g),p;if(l!=null&&o.has(l)){let v=o.get(l);o.delete(l),d.add(v);let T=n[v];v<h?e.insertBefore(T,f):h=v,p=te(T,g)}else if(l==null){let v=H();if(v>=0&&Pe(n[v],g)){d.add(v);let T=n[v];T.parentNode===e&&T.nextSibling!==f&&e.insertBefore(T,f),p=te(T,g)}else p=document.importNode(g,!0),e.insertBefore(p,f)}else p=document.importNode(g,!0),e.insertBefore(p,f);f=p.nextSibling}n.forEach((g,l)=>{!d.has(l)&&g.parentNode===e&&(L(g),e.removeChild(g))})}function ne(e,t){if(e.nodeType!==Node.ELEMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return;let n=e,r=t;if(n.tagName!==r.tagName){let o=document.importNode(t,!0);n.parentNode&&n.parentNode.replaceChild(o,n);return}Ne(n,r),Oe(n,r)}var re=!1,R,U=null,C=new Map,bt=30,D=new Map,ft=50,Re=/\/chunks\/runtime\.[^/]+\.js$/;function De(){if(typeof document=="undefined"||re)return;re=!0;let e=".docs-content, main, #root",t=150,n=200,r=null,o=null,u=new Map,d=null;function h(i){for(let s of e.split(", ")){let a=i.querySelector(s.trim());if(a)return a}return i.body}function f(i){if(i.hasAttribute("data-krate-external"))return!1;let s=i.getAttribute("href");return!(!s||s.startsWith("#")||s.startsWith("javascript:")||i.origin!==location.origin||i.target==="_blank")}function m(i){C.has(i)||fetch(i,{headers:{Accept:"text/html"}}).then(s=>s.ok?s.text():null).then(s=>{if(s){if(C.size>=bt){let a=C.keys().next().value;a!==void 0&&C.delete(a)}C.set(i,s)}}).catch(()=>{})}function H(){document.addEventListener("mouseover",p),document.addEventListener("focusin",p),typeof IntersectionObserver!="undefined"&&(d=new IntersectionObserver(i=>{for(let s of i)if(s.isIntersecting){let a=s.target,c=a.getAttribute("href");if(c&&f(a)){let b=new URL(c,location.origin).href;m(b)}d.unobserve(s.target)}},{rootMargin:"200px"}),g())}function g(){d&&document.querySelectorAll("a[data-prefetch]").forEach(i=>{d.observe(i)})}function l(){document.removeEventListener("mouseover",p),document.removeEventListener("focusin",p);for(let i of u.values())clearTimeout(i);u.clear(),d&&(d.disconnect(),d=null)}function p(i){let s=i.target.closest("a[data-prefetch]");if(!s||!f(s))return;let a=s.getAttribute("href");if(!a)return;let c=new URL(a,location.origin).href;if(C.has(c))return;let b=u.get(s);b&&clearTimeout(b);let E=setTimeout(()=>{u.delete(s),m(c)},n);u.set(s,E)}function v(i){let s=document.createTreeWalker(i,NodeFilter.SHOW_ELEMENT),a=s.nextNode();for(;a;){let c=a;for(let b of Object.keys(c))b.indexOf("__krate_")===0&&delete c[b];a=s.nextNode()}}let T=null;function ie(){let i=h(document),s=document.querySelector("template[data-krate-loading]");s&&s.content&&i&&(T=s.content.cloneNode(!0),document.body.appendChild(T)),i&&(i.style.transition=`opacity ${t}ms ease`,i.style.opacity="0")}function y(){T&&T.parentNode&&T.parentNode.removeChild(T),T=null;let i=h(document);i&&(i.style.opacity="1")}function I(i,s,a,c={}){let{replace:b=!1,scroll:E=!0,restoreScroll:N=!1}=c,z=new DOMParser().parseFromString(i,"text/html"),be=h(z),j=h(document);if(!be||!j){location.href=s;return}let fe=z.querySelector("title");fe&&(document.title=fe.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),v(j),ne(j,be);let me=z.querySelectorAll('link[rel="stylesheet"]'),pe=new Set;me.forEach(A=>{let M=A.getAttribute("href");M&&pe.add(M)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(A=>{let M=A.getAttribute("href");M&&!pe.has(M)&&A.remove()});let he=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(A=>{he.add(A.href)}),me.forEach(A=>{let M=A.getAttribute("href");if(M&&!he.has(M)){let K=document.createElement("link");K.rel="stylesheet",K.href=M,document.head.appendChild(K)}}),Ie(a,s).then(()=>{try{_e(),g()}catch(A){try{let M=globalThis.__krate_onHydrationError;typeof M=="function"&&M(A)}catch(M){}location.href=s}}),y();let Ue=location.pathname+location.search;if(b)history.replaceState({},"",s);else{if(!N){if(D.size>=ft){let A=D.keys().next().value;A!==void 0&&D.delete(A)}D.set(Ue,window.scrollY)}history.pushState({},"",s)}se(s,{restoreScroll:N,scroll:E}),oe(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:s}}))}function S(i){let s=i.indexOf("#");if(s<0||s===i.length-1)return!1;let a=i.slice(s);try{let c=document.querySelector(a);if(c)return c.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch(c){return!1}return!1}function se(i,s){if(s.restoreScroll){let a=D.get(i);if(a!==void 0){window.scrollTo(0,a);return}}S(i)||s.scroll&&window.scrollTo(0,0)}function oe(){let i=location.pathname;document.querySelectorAll("a[data-krate-link]").forEach(s=>{let a=s.getAttribute("href");if(!a){s.removeAttribute("aria-current");return}let c=a;try{c=new URL(a,location.origin).pathname}catch(E){return}c===i||i==="/"&&(c===""||c==="/")||c!=="/"&&c.length>1&&i.startsWith(c)?s.setAttribute("aria-current","page"):s.removeAttribute("aria-current")})}function Ie(i,s){return i.length===0?Promise.resolve():Promise.all(i.map(a=>{let c=a.getAttribute("src");return c?Be(c,s):Promise.resolve()})).then(()=>{})}function Be(i,s){return new Promise(a=>{let c=document.createElement("script"),b=ae(i,s);c.src=b,Re.test(b)||c.setAttribute("data-krate-spa",""),c.onload=()=>a(),c.onerror=()=>a(),document.body.appendChild(c)})}function ae(i,s){if(/^(https?:)?\/\//.test(i)||i.startsWith("/"))return new URL(i,s).href;let a=s;if(!a.endsWith("/")){let c=a.lastIndexOf("/");a=c>0?a.slice(0,c+1):"/"}return new URL(i,a).href}function _e(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function qe(i,s){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",s),document.open(),document.write(i),document.close()}function Fe(){return r!==null?Promise.resolve(r):fetch("/404.html",{headers:{Accept:"text/html"}}).then(i=>i.ok?i.text():null).then(i=>(r=i,i)).catch(()=>null)}function Ve(){return o!==null?Promise.resolve(o):fetch("/500.html",{headers:{Accept:"text/html"}}).then(i=>i.ok?i.text():null).then(i=>(o=i,i)).catch(()=>null)}function ue(i,s){document.querySelectorAll("script[data-krate-spa]").forEach(b=>b.remove());let a=[],c=new Set;return document.querySelectorAll("script[src]").forEach(b=>{c.add(b.src)}),i.querySelectorAll("script[src]").forEach(b=>{let E=b.getAttribute("src");E&&!c.has(ae(E,s))&&a.push(b)}),a}function le(i,s={}){let a=C.get(i);if(a){let E=new DOMParser().parseFromString(a,"text/html");I(a,i,ue(E,i),s);return}ie(),R&&R.abort(),R=new AbortController;let c=R.signal;fetch(i,{headers:{Accept:"text/html"},signal:c}).then(b=>b.ok?b.text().then(E=>{let ge=new DOMParser().parseFromString(E,"text/html");I(E,i,ue(ge,i),s)}):(b.status>=500?Ve():Fe()).then(N=>{N?qe(N,i):location.href=i})).catch(b=>{(b==null?void 0:b.name)!=="AbortError"&&(y(),location.href=i)}).finally(()=>{R&&!c.aborted&&(R=void 0)})}let ce=i=>{if(i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey)return;let s=i.target.closest("a[data-krate-link]");if(!s||!f(s))return;i.preventDefault();let a=s.getAttribute("href");if(!a)return;let c=new URL(a,location.origin).href,b=s.hasAttribute("data-krate-replace"),E=s.getAttribute("data-krate-scroll")!=="false";if(a===location.pathname+location.search+location.hash){b&&history.replaceState({},"",a),se(c,{scroll:E});return}le(c,{replace:b,scroll:E})},de=()=>{le(location.href,{restoreScroll:!0})};document.addEventListener("click",ce),window.addEventListener("popstate",de),H(),oe(),document.querySelectorAll("script[src]").forEach(i=>{Re.test(i.src)||i.setAttribute("data-krate-spa","")}),U=()=>{document.removeEventListener("click",ce),window.removeEventListener("popstate",de),l()}}function mt(){U&&(U(),U=null),re=!1,De()}return Je(pt);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
package/dist/resource.js CHANGED
@@ -56,10 +56,17 @@ export function createResource(source, fetcher) {
56
56
  }
57
57
  });
58
58
  });
59
- const resource = Object.assign(data, {
60
- get loading() { return loading(); },
61
- get error() { return error(); },
62
- get state() { return state(); },
59
+ // Note: use Object.defineProperties, NOT Object.assign, for these getters.
60
+ // Object.assign evaluates source getters via [[Set]] and copies the *value*
61
+ // as a plain data property, snapshotting state/loading/error once at creation
62
+ // so they never track reactive updates. defineProperties installs live accessors.
63
+ const resource = function () {
64
+ return data();
65
+ };
66
+ Object.defineProperties(resource, {
67
+ loading: { get: () => loading() },
68
+ error: { get: () => error() },
69
+ state: { get: () => state() },
63
70
  });
64
71
  const actions = {
65
72
  mutate: (fn) => {
package/dist/router.js CHANGED
@@ -227,9 +227,25 @@ export function initRouter() {
227
227
  });
228
228
  // Load new scripts, then rehydrate
229
229
  loadScripts(scripts, url).then(() => {
230
- rehydrate();
231
- // Re-observe new prefetch links after hydration
232
- observePrefetchLinks();
230
+ try {
231
+ rehydrate();
232
+ observePrefetchLinks();
233
+ }
234
+ catch (err) {
235
+ // Hydration threw (e.g. a page-side error or a compiler emission bug).
236
+ // Rather than leave the route half-mounted against a live SPA DOM,
237
+ // fall back to a full page load of the SSR HTML. The optional global
238
+ // hook lets embedders be notified; a throw inside the hook is ignored.
239
+ try {
240
+ const hook = globalThis.__krate_onHydrationError;
241
+ if (typeof hook === 'function')
242
+ hook(err);
243
+ }
244
+ catch {
245
+ /* ignore hook failures */
246
+ }
247
+ location.href = url;
248
+ }
233
249
  });
234
250
  endTransition();
235
251
  // History: replace keeps the current entry; push appends one (unless we
package/dist/server.d.ts CHANGED
@@ -2,7 +2,7 @@ export declare function createSignal<T>(initial: T): [() => T, (v: T | ((prev: T
2
2
  export declare function createEffect(_fn: () => void): () => void;
3
3
  export declare function createMemo<T>(fn: () => T): () => T;
4
4
  export declare function onCleanup(_fn: () => void): void;
5
- export declare function onMount(fn: () => void): void;
5
+ export declare function onMount(_fn: () => void): void;
6
6
  interface RawHTML {
7
7
  __raw: string;
8
8
  }
package/dist/server.js CHANGED
@@ -27,9 +27,10 @@ export function createMemo(fn) {
27
27
  export function onCleanup(_fn) {
28
28
  // No-op on server
29
29
  }
30
- export function onMount(fn) {
31
- // On server, run immediately (synchronous)
32
- fn();
30
+ export function onMount(_fn) {
31
+ // No-op on server: onMount callbacks (DOM setup, WebGL renderers, timers) are
32
+ // client-only. Running them during SSR would touch a DOM that doesn't exist
33
+ // and crash.
33
34
  }
34
35
  function raw(html) { return { __raw: html }; }
35
36
  export function Fragment(_props) {
package/dist/signal.d.ts CHANGED
@@ -4,6 +4,33 @@ export declare function createEffect(fn: () => void): () => void;
4
4
  export declare function onCleanup(fn: () => void): void;
5
5
  export declare function onMount(fn: () => void): void;
6
6
  export declare function createMemo<T>(fn: () => T): () => T;
7
- export declare function forwardRef<P>(renderFn: (props: P, ref: (el: Element) => void) => Node | null | undefined): (props: P & {
8
- ref?: (el: Element) => void;
7
+ /** A mutable ref object. `current` starts as `initial` and is assigned the
8
+ * DOM element when passed as `ref={refObj}` on an element. */
9
+ export interface RefObject<T> {
10
+ current: T;
11
+ }
12
+ /** A ref that may be a plain callback or a `{current}` object. */
13
+ export type Ref<T> = RefCallback<T> | RefObject<T | null>;
14
+ /** A callback-style ref: invoked with the element (or null on cleanup). */
15
+ export type RefCallback<T> = (el: T) => void;
16
+ /** Result type of the {@link useRef} hook's component-level ref: an object
17
+ * whose `current` is set by `ref={refObj}` bindings. */
18
+ export type UseRefResult<T> = RefObject<T>;
19
+ /**
20
+ * Create a mutable ref object. Unlike React, `useRef` always allocates a
21
+ * fresh `{current: initial}` object; Krate components run their body once per
22
+ * mount (client) and once per evaluation (SSR), so the object naturally
23
+ * persists for the component's lifetime without additional bookkeeping.
24
+ *
25
+ * Pass the object as `ref={myRef}` on a DOM element to have `.current` set to
26
+ * the element, or read/write `.current` directly for imperative handles.
27
+ */
28
+ export declare function useRef<T>(initial: T): UseRefResult<T>;
29
+ /**
30
+ * Pass `ref` through a forwarding component to the underlying element or
31
+ * component. The ref may be either a callback or a `{current}` object; both
32
+ * are invoked/assigned with the forwarded element.
33
+ */
34
+ export declare function forwardRef<P>(renderFn: (props: P, ref: Ref<Element>) => Node | null | undefined): (props: P & {
35
+ ref?: Ref<Element>;
9
36
  }) => Node | null | undefined;
package/dist/signal.js CHANGED
@@ -2,6 +2,11 @@ const context = [];
2
2
  const mountQueue = [];
3
3
  let mountScheduled = false;
4
4
  const allEffects = new Set();
5
+ // Top-level onCleanup registrations (called outside an effect body) are scoped
6
+ // to the page/root and run when disposeAll() executes on route change. This
7
+ // gives component-level cleanup semantics: a component's top-level onCleanup
8
+ // registers once when its hydration IIFE runs and is invoked on unmount.
9
+ const rootCleanups = [];
5
10
  // Pending effects scheduled to re-run in the next microtask. Writes batch
6
11
  // subscriber re-runs into a single flush so N writes in a loop (or one write
7
12
  // fanning out) produce one pass instead of N synchronous effect runs.
@@ -30,6 +35,15 @@ export function disposeAll() {
30
35
  disposeEffect(effect);
31
36
  }
32
37
  allEffects.clear();
38
+ for (const cleanup of rootCleanups) {
39
+ try {
40
+ cleanup();
41
+ }
42
+ catch {
43
+ // Cleanup errors must not prevent remaining cleanups or DOM swap.
44
+ }
45
+ }
46
+ rootCleanups.length = 0;
33
47
  pending.length = 0;
34
48
  flushScheduled = false;
35
49
  }
@@ -132,6 +146,11 @@ export function onCleanup(fn) {
132
146
  if (current) {
133
147
  current.cleanups.push(fn);
134
148
  }
149
+ else {
150
+ // No active effect: treat as a root/component-level cleanup, run on
151
+ // disposeAll() (route change / page teardown).
152
+ rootCleanups.push(fn);
153
+ }
135
154
  }
136
155
  export function onMount(fn) {
137
156
  mountQueue.push(fn);
@@ -173,6 +192,23 @@ export function createMemo(fn) {
173
192
  }
174
193
  return get;
175
194
  }
195
+ /**
196
+ * Create a mutable ref object. Unlike React, `useRef` always allocates a
197
+ * fresh `{current: initial}` object; Krate components run their body once per
198
+ * mount (client) and once per evaluation (SSR), so the object naturally
199
+ * persists for the component's lifetime without additional bookkeeping.
200
+ *
201
+ * Pass the object as `ref={myRef}` on a DOM element to have `.current` set to
202
+ * the element, or read/write `.current` directly for imperative handles.
203
+ */
204
+ export function useRef(initial) {
205
+ return { current: initial };
206
+ }
207
+ /**
208
+ * Pass `ref` through a forwarding component to the underlying element or
209
+ * component. The ref may be either a callback or a `{current}` object; both
210
+ * are invoked/assigned with the forwarded element.
211
+ */
176
212
  export function forwardRef(renderFn) {
177
213
  return (props) => renderFn(props, props.ref || (() => { }));
178
214
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krate/runtime",
3
- "version": "0.3.0-beta.2",
3
+ "version": "0.3.0-beta.4",
4
4
  "description": "Client-side runtime for Krate — signals, hydration, SPA router, resources, and context.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",