@krate/runtime 0.3.0 → 0.4.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,25 @@
1
1
  declare global {
2
+ /**
3
+ * Extension point for Krate-generated types. `krate build` writes
4
+ * `krate-env.d.ts`, which augments these interfaces with the project's
5
+ * routes and content collections (see `.krate/types/`).
6
+ *
7
+ * `TypedRoutes` is intentionally empty by default so the runtime type-checks
8
+ * with no generated files present.
9
+ */
10
+ namespace Krate {
11
+ interface TypedRoutes {
12
+ }
13
+ }
14
+ /**
15
+ * A navigation target. When the project has generated route types,
16
+ * `Krate.TypedRoutes.href` is a union of its routes, which gives `<Link href>`
17
+ * and `<a href>` autocomplete. `string` is always accepted so arbitrary URLs
18
+ * (external, query strings, hashes) keep working.
19
+ */
20
+ type KrateHref = Krate.TypedRoutes extends {
21
+ href: infer H;
22
+ } ? H extends string ? H | (string & {}) : string : string;
2
23
  namespace JSX {
3
24
  interface Element extends Node {
4
25
  }
@@ -221,7 +242,7 @@ declare global {
221
242
  }
222
243
  interface AnchorHTMLAttributes extends HTMLAttributes {
223
244
  download?: string;
224
- href?: string;
245
+ href?: KrateHref;
225
246
  hrefLang?: string;
226
247
  media?: string;
227
248
  ping?: string;
@@ -995,7 +1016,7 @@ declare global {
995
1016
  [key: string]: any;
996
1017
  }
997
1018
  interface LinkProps extends AnchorHTMLAttributes {
998
- href: string;
1019
+ href: KrateHref;
999
1020
  className?: string;
1000
1021
  external?: boolean;
1001
1022
  children?: any;
@@ -1,2 +1,2 @@
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 ve(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=ve(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=ve(()=>{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 Ne(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(()=>Ne(r,c,a()))):Ne(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"),[v,d]=C(0),l,g=()=>typeof e=="function"?e():e,T=async()=>{l&&l.abort(),l=new AbortController;let A=l,q=g();m(v()>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(),v(),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=[],v=new Set;for(let d=0;d<r.length;d++){let l=r[d],g=a(l);v.add(g);let T=c(l,d);T.__k=g,m.push(T)}for(let[d,l]of h)!v.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 v=c(r[m],m);m<u.length?u[m]!==v&&(x(u[m]),e.replaceChild(v,u[m])):e.insertBefore(v,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,v=()=>{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=v();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 v(){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(N=>{let S=N.getAttribute("href");S&&pe.add(S)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(N=>{let S=N.getAttribute("href");S&&!pe.has(S)&&N.remove()});let he=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(N=>{he.add(N.href)}),de.forEach(N=>{let S=N.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(N){try{let S=globalThis.__krate_onHydrationError;typeof S=="function"&&S(N)}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 N=O.keys().next().value;N!==void 0&&O.delete(N)}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),v(),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);})();
1
+ var __krate_exports=(()=>{var D=Object.defineProperty,je=Object.defineProperties,Be=Object.getOwnPropertyDescriptor,Ke=Object.getOwnPropertyDescriptors,Ue=Object.getOwnPropertyNames,me=Object.getOwnPropertySymbols;var ye=Object.prototype.hasOwnProperty,We=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))We.call(t,n)&&ge(e,n,t[n]);return e},Te=(e,t)=>je(e,Ke(t));var Fe=(e,t)=>{for(var n in t)D(e,n,{get:t[n],enumerable:!0})},$e=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of Ue(t))!ye.call(e,c)&&c!==n&&D(e,c,{get:()=>t[c],enumerable:!(r=Be(t,c))||r.enumerable});return e};var ze=e=>$e(D({},"__esModule",{value:!0}),e);var pt={};Fe(pt,{clearNodes:()=>xe,conditional:()=>at,createEffect:()=>w,createMemo:()=>Ze,createResource:()=>ct,createSignal:()=>C,disposeAll:()=>Xe,disposeNode:()=>x,forwardRef:()=>tt,h:()=>rt,hydrate:()=>st,initRouter:()=>Re,insert:()=>ot,mount:()=>it,onCleanup:()=>X,onMount:()=>Ge,reconcile:()=>lt,reconcileTrees:()=>Z,reinitRouter:()=>dt,useRef:()=>et});var L=[],be=[],W=!1,H=new Set,F=[],$=[],I=!1;function ve(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 Xe(){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 f=L[L.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 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))}Ye()}}]}function Ye(){I||(I=!0,queueMicrotask(Qe))}function Qe(){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 w(e){let t=ve(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 Ge(e){be.push(e),W||(W=!0,queueMicrotask(Je))}function Je(){W=!1;let e=be.splice(0);for(let t of e)t()}function Ze(e){let[t,n]=C(void 0),r=ve(()=>{let f=e();n(f)});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 et(e){return{current:e}}function tt(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 nt(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 ot(e,t,n){let r=nt(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 Ne(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}`,f=e[c];f&&e.removeEventListener(r,f),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,w(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function rt(e,t,...n){if(typeof e=="function")return e(Te(Ee({},t||{}),{children:n}));let r=document.createElement(e);if(t)for(let[c,f]of Object.entries(t))typeof f=="function"&&!c.startsWith("on")?Se(r,w(()=>Ne(r,c,f()))):Ne(r,c,f);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 it(e,t){let n=ke(t),r=!1;w(()=>{r||(r=!0,n.appendChild(e()))})}function st(e,t){let n=ke(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&x(r)}function ct(e,t){let[n,r]=C(void 0),[c,f]=C(!0),[u,y]=C(void 0),[h,m]=C("unresolved"),[v,d]=C(0),l,g=()=>typeof e=="function"?e():e,T=async()=>{l&&l.abort(),l=new AbortController;let A=l,q=g();m(v()>0?"refreshing":"loading"),f(!0),y(void 0);try{let k=await t(q,{signal:A.signal});A.signal.aborted||(r(()=>k),m("ready"))}catch(k){(k==null?void 0:k.name)!=="AbortError"&&!A.signal.aborted&&(y(k),m("error"))}finally{A.signal.aborted||f(!1)}};w(()=>{typeof e=="function"&&e.length===0&&e(),v(),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 lt(e,t,n,r,c,f){let u=[],y=t.nextSibling;for(;y&&y!==n;)u.push(y),y=y.nextSibling;if(f){let h=new Map;for(let d of u){let l=d.__k;l!=null&&h.set(l,d)}let m=[],v=new Set;for(let d=0;d<r.length;d++){let l=r[d],g=f(l);v.add(g);let T=c(l,d);T.__k=g,m.push(T)}for(let[d,l]of h)!v.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 v=c(r[m],m);m<u.length?u[m]!==v&&(x(u[m]),e.replaceChild(v,u[m])):e.insertBefore(v,n)}else m<u.length&&u[m].parentNode===e&&(x(u[m]),e.removeChild(u[m]))}}function at(e,t,n,r,c,f){let u=null;w(()=>{let h=r()?c():f?f():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,f=t.attributes[r].value;n.add(c),e.getAttribute(c)!==f&&e.setAttribute(c,f)}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,f=[];n.forEach((d,l)=>{let g=P(d);g!=null?c.has(g)||c.set(g,l):f.push(l)});let u=new Set,y=0,h=null,m=0,v=()=>{for(;m<f.length&&u.has(f[m]);)m++;return m<f.length?f[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=v();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,ut=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,f=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 v(){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,a=s.getAttribute("href");if(a&&h(s)){let p=new URL(a,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 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 a=new URL(s,location.origin).href;if(M.has(a))return;let p=f.get(i);p&&clearTimeout(p);let b=setTimeout(()=>{f.delete(i),m(a)},n);f.set(i,b)}function T(o){let i=document.createTreeWalker(o,NodeFilter.SHOW_ELEMENT),s=i.nextNode();for(;s;){let a=s;for(let p of Object.keys(a))p.indexOf("__krate_")===0&&delete a[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){try{let i=globalThis.__krate_onNavigation;typeof i=="function"&&i(o)}catch(i){}}function k(o,i,s,a={}){let{replace:p=!1,scroll:b=!0,restoreScroll:R=!1}=a,B=new DOMParser().parseFromString(o,"text/html"),fe=y(B),K=y(document);if(!fe||!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,fe);let de=B.querySelectorAll('link[rel="stylesheet"]'),pe=new Set;de.forEach(N=>{let S=N.getAttribute("href");S&&pe.add(S)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(N=>{let S=N.getAttribute("href");S&&!pe.has(S)&&N.remove()});let he=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(N=>{he.add(N.href)}),de.forEach(N=>{let S=N.getAttribute("href");if(S&&!he.has(S)){let U=document.createElement("link");U.rel="stylesheet",U.href=S,document.head.appendChild(U)}}),Pe(s,i).then(()=>{try{Oe(),d()}catch(N){try{let S=globalThis.__krate_onHydrationError;typeof S=="function"&&S(N)}catch(S){}location.href=i}}),A();let Ve=location.pathname+location.search;if(p)history.replaceState({},"",i);else{if(!R){if(O.size>=ut){let N=O.keys().next().value;N!==void 0&&O.delete(N)}O.set(Ve,window.scrollY)}history.pushState({},"",i)}ne(i,{restoreScroll:R,scroll:b}),oe(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:i}})),q(i)}function He(o){let i=o.indexOf("#");if(i<0||i===o.length-1)return!1;let s=o.slice(i);try{let a=document.querySelector(s);if(a)return a.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch(a){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}}He(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 a=s;try{a=new URL(s,location.origin).pathname}catch(b){return}a===o||o==="/"&&(a===""||a==="/")||a!=="/"&&a.length>1&&o.startsWith(a)?i.setAttribute("aria-current","page"):i.removeAttribute("aria-current")})}function Pe(o,i){return o.length===0?Promise.resolve():Promise.all(o.map(s=>{let a=s.getAttribute("src");return a?_e(a,i):Promise.resolve()})).then(()=>{})}function _e(o,i){return new Promise(s=>{let a=document.createElement("script"),p=re(o,i);a.src=p,Me.test(p)||a.setAttribute("data-krate-spa",""),a.onload=()=>s(),a.onerror=()=>s(),document.body.appendChild(a)})}function re(o,i){if(/^(https?:)?\/\//.test(o)||o.startsWith("/"))return new URL(o,i).href;let s=i;if(!s.endsWith("/")){let a=s.lastIndexOf("/");s=a>0?s.slice(0,a+1):"/"}return new URL(o,s).href}function Oe(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function qe(o,i){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",i),q(i),document.open(),document.write(o),document.close()}function De(){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 Ie(){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=[],a=new Set;return document.querySelectorAll("script[src]").forEach(p=>{a.add(p.src)}),o.querySelectorAll("script[src]").forEach(p=>{let b=p.getAttribute("src");b&&!a.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");k(s,o,ie(b,o),i);return}te(),_&&_.abort(),_=new AbortController;let a=_.signal;fetch(o,{headers:{Accept:"text/html"},signal:a}).then(p=>p.ok?p.text().then(b=>{let ae=new DOMParser().parseFromString(b,"text/html");k(b,o,ie(ae,o),i)}):(p.status>=500?Ie():De()).then(R=>{R?qe(R,o):location.href=o})).catch(p=>{(p==null?void 0:p.name)!=="AbortError"&&(A(),location.href=o)}).finally(()=>{_&&!a.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 a=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(a,{scroll:b});return}se(a,{replace:p,scroll:b})},le=()=>{se(location.href,{restoreScroll:!0})};document.addEventListener("click",ce),window.addEventListener("popstate",le),v(),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 dt(){j&&(j(),j=null),ee=!1,Re()}return ze(pt);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
@@ -1,2 +1,2 @@
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);})();
1
+ var __krate_exports=(()=>{var B=Object.defineProperty,Ke=Object.defineProperties,je=Object.getOwnPropertyDescriptor,We=Object.getOwnPropertyDescriptors,Xe=Object.getOwnPropertyNames,_=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var Te=(e,t,n)=>t in e?B(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,He=(e,t)=>{for(var n in t||(t={}))W.call(t,n)&&Te(e,n,t[n]);if(_)for(var n of _(t))ve.call(t,n)&&Te(e,n,t[n]);return e},Ee=(e,t)=>Ke(e,We(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&&_)for(var r of _(e))t.indexOf(r)<0&&ve.call(e,r)&&(n[r]=e[r]);return n};var Ge=(e,t)=>{for(var n in t)B(e,n,{get:t[n],enumerable:!0})},Je=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Xe(t))!W.call(e,o)&&o!==n&&B(e,o,{get:()=>t[o],enumerable:!(r=je(t,o))||r.enumerable});return e};var Ye=e=>Je(B({},"__esModule",{value:!0}),e);var ht={};Ge(ht,{Fragment:()=>ct,clearNodes:()=>Se,conditional:()=>bt,createEffect:()=>S,createMemo:()=>nt,createResource:()=>lt,createSignal:()=>w,disposeAll:()=>$e,disposeNode:()=>L,forwardRef:()=>it,h:()=>V,hydrate:()=>ut,initRouter:()=>De,insert:()=>ot,jsx:()=>Ce,jsxs:()=>dt,mount:()=>at,onCleanup:()=>$,onMount:()=>et,reconcile:()=>gt,reconcileTrees:()=>ne,reinitRouter:()=>pt,useRef:()=>rt});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 $e(){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))}Qe()}}]}function Qe(){q||(q=!0,queueMicrotask(Ze))}function Ze(){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 S(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 et(e){Me.push(e),X||(X=!0,queueMicrotask(tt))}function tt(){X=!1;let e=Me.splice(0);for(let t of e)t()}function nt(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 rt(e){return{current:e}}function it(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 st(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 ot(e,t,n){let r=st(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,S(()=>{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(Ee(He({},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,S(()=>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 at(e,t){let n=we(t),r=!1;S(()=>{r||(r=!0,n.appendChild(e()))})}function ut(e,t){let n=we(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&L(r)}function lt(e,t){let[n,r]=w(void 0),[o,u]=w(!0),[d,h]=w(void 0),[f,m]=w("unresolved"),[E,g]=w(0),l,p=()=>typeof e=="function"?e():e,v=async()=>{l&&l.abort(),l=new AbortController;let y=l,I=p();m(E()>0?"refreshing":"loading"),u(!0),h(void 0);try{let x=await t(I,{signal:y.signal});y.signal.aborted||(r(()=>x),m("ready"))}catch(x){(x==null?void 0:x.name)!=="AbortError"&&!y.signal.aborted&&(h(x),m("error"))}finally{y.signal.aborted||u(!1)}};S(()=>{typeof e=="function"&&e.length===0&&e(),E(),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 ct(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 dt(e,t,n){return Ce(e,t,n)}function gt(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=[],E=new Set;for(let g=0;g<r.length;g++){let l=r[g],p=u(l);E.add(p);let v=o(l,g);v.__k=p,m.push(v)}for(let[g,l]of f)!E.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 E=o(r[m],m);m<d.length?d[m]!==E&&(L(d[m]),e.replaceChild(E,d[m])):e.insertBefore(E,n)}else m<d.length&&d[m].parentNode===e&&(L(d[m]),e.removeChild(d[m]))}}function bt(e,t,n,r,o,u){let d=null;S(()=>{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,E=()=>{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=E();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,ft=30,D=new Map,mt=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>=ft){let a=C.keys().next().value;a!==void 0&&C.delete(a)}C.set(i,s)}}).catch(()=>{})}function E(){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 H=setTimeout(()=>{u.delete(s),m(c)},n);u.set(s,H)}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){try{let s=globalThis.__krate_onNavigation;typeof s=="function"&&s(i)}catch(s){}}function x(i,s,a,c={}){let{replace:b=!1,scroll:H=!0,restoreScroll:N=!1}=c,z=new DOMParser().parseFromString(i,"text/html"),be=h(z),K=h(document);if(!be||!K){location.href=s;return}let fe=z.querySelector("title");fe&&(document.title=fe.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),v(K),ne(K,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 j=document.createElement("link");j.rel="stylesheet",j.href=M,document.head.appendChild(j)}}),_e(a,s).then(()=>{try{qe(),g()}catch(A){try{let M=globalThis.__krate_onHydrationError;typeof M=="function"&&M(A)}catch(M){}location.href=s}}),y();let ze=location.pathname+location.search;if(b)history.replaceState({},"",s);else{if(!N){if(D.size>=mt){let A=D.keys().next().value;A!==void 0&&D.delete(A)}D.set(ze,window.scrollY)}history.pushState({},"",s)}se(s,{restoreScroll:N,scroll:H}),oe(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:s}})),I(s)}function Ie(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}}Ie(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(H){return}c===i||i==="/"&&(c===""||c==="/")||c!=="/"&&c.length>1&&i.startsWith(c)?s.setAttribute("aria-current","page"):s.removeAttribute("aria-current")})}function _e(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 qe(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function Fe(i,s){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",s),I(s),document.open(),document.write(i),document.close()}function Ve(){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 Ue(){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 H=b.getAttribute("src");H&&!c.has(ae(H,s))&&a.push(b)}),a}function le(i,s={}){let a=C.get(i);if(a){let H=new DOMParser().parseFromString(a,"text/html");x(a,i,ue(H,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(H=>{let ge=new DOMParser().parseFromString(H,"text/html");x(H,i,ue(ge,i),s)}):(b.status>=500?Ue():Ve()).then(N=>{N?Fe(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"),H=s.getAttribute("data-krate-scroll")!=="false";if(a===location.pathname+location.search+location.hash){b&&history.replaceState({},"",a),se(c,{scroll:H});return}le(c,{replace:b,scroll:H})},de=()=>{le(location.href,{restoreScroll:!0})};document.addEventListener("click",ce),window.addEventListener("popstate",de),E(),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 pt(){U&&(U(),U=null),re=!1,De()}return Ye(ht);})();
2
2
  for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
package/dist/router.js CHANGED
@@ -174,6 +174,19 @@ export function initRouter() {
174
174
  oldContent.style.opacity = '1';
175
175
  }
176
176
  }
177
+ // Analytics hook: fires once after every successful SPA navigation
178
+ // (click, prefetch-cache, back/forward, and error-page replacements all flow
179
+ // through swapContent/replacePage). A throw inside the hook is ignored.
180
+ function notifyNavigation(url) {
181
+ try {
182
+ const hook = globalThis.__krate_onNavigation;
183
+ if (typeof hook === 'function')
184
+ hook(url);
185
+ }
186
+ catch {
187
+ /* ignore hook failures */
188
+ }
189
+ }
177
190
  function swapContent(html, url, scripts, opts = {}) {
178
191
  const { replace = false, scroll = true, restoreScroll = false } = opts;
179
192
  const parser = new DOMParser();
@@ -268,6 +281,7 @@ export function initRouter() {
268
281
  applyScroll(url, { restoreScroll, scroll });
269
282
  updateActiveLinks();
270
283
  window.dispatchEvent(new CustomEvent('krate:navigate', { detail: { url } }));
284
+ notifyNavigation(url);
271
285
  }
272
286
  function handleHashScroll(url) {
273
287
  const hashIdx = url.indexOf('#');
@@ -374,6 +388,7 @@ export function initRouter() {
374
388
  globalThis.disposeAll();
375
389
  }
376
390
  history.pushState({}, '', url);
391
+ notifyNavigation(url);
377
392
  document.open();
378
393
  document.write(html);
379
394
  document.close();
@@ -65,6 +65,17 @@ class ISRCache {
65
65
  }
66
66
  }
67
67
  }
68
+ // entriesForRoute returns a snapshot of the cached variants for a route so a
69
+ // background refresh can iterate them without mutating during iteration.
70
+ entriesForRoute(route) {
71
+ const out = [];
72
+ for (const [key, entry] of this.cache) {
73
+ if (key === route || key.startsWith(route + "?") || key.startsWith(route + "#")) {
74
+ out.push([key, entry]);
75
+ }
76
+ }
77
+ return out;
78
+ }
68
79
  serialize() {
69
80
  return {
70
81
  entries: [...this.cache.entries()].map(([key, entry]) => ({ key, ...entry })),
@@ -78,6 +89,8 @@ class ISRCache {
78
89
  this.cache.set(e.key, {
79
90
  html: e.html,
80
91
  timestamp: typeof e.timestamp === "number" ? e.timestamp : Date.now(),
92
+ params: e.params && typeof e.params === "object" ? e.params : undefined,
93
+ query: e.query && typeof e.query === "object" ? e.query : undefined,
81
94
  });
82
95
  }
83
96
  }
@@ -199,6 +212,8 @@ async function renderFresh(page, req) {
199
212
  isrCache.set(variantKey(req), {
200
213
  html,
201
214
  timestamp: Date.now(),
215
+ params: req.params,
216
+ query: req.query,
202
217
  });
203
218
  scheduleIsrPersist();
204
219
  }
@@ -233,6 +248,42 @@ function revalidateInBackground(page, req) {
233
248
  })();
234
249
  inFlightRevalidations.set(key, p);
235
250
  }
251
+ // Time-based ISR regeneration: re-render every cached variant of a route while
252
+ // keeping the entries in place. This is the non-destructive counterpart of
253
+ // /__krate/ssr/revalidate (which clears a route). The Go server's periodic ISR
254
+ // timer calls this so cached pages stay fresh without evicting dynamic
255
+ // variants — eviction would turn a request that should be a HIT into a MISS.
256
+ const inFlightRouteRefreshes = new Map();
257
+ function refreshRouteVariants(page) {
258
+ const running = inFlightRouteRefreshes.get(page.route);
259
+ if (running)
260
+ return running;
261
+ const p = (async () => {
262
+ try {
263
+ const variants = isrCache.entriesForRoute(page.route);
264
+ let refreshed = 0;
265
+ for (const [, entry] of variants) {
266
+ const req = {
267
+ route: page.route,
268
+ url: page.route,
269
+ method: "GET",
270
+ headers: {},
271
+ params: entry.params,
272
+ query: entry.query,
273
+ };
274
+ const rendered = await renderFresh(page, req);
275
+ if (rendered.status === 200)
276
+ refreshed++;
277
+ }
278
+ return refreshed;
279
+ }
280
+ finally {
281
+ inFlightRouteRefreshes.delete(page.route);
282
+ }
283
+ })();
284
+ inFlightRouteRefreshes.set(page.route, p);
285
+ return p;
286
+ }
236
287
  async function renderPage(req) {
237
288
  const page = findPage(req.route);
238
289
  if (!page) {
@@ -348,7 +399,7 @@ async function renderRegion(page, region, req) {
348
399
  const cached = regionCache.get(key);
349
400
  const stale = cached && (Date.now() - cached.timestamp) / 1000 > interval;
350
401
  if (cached && !stale) {
351
- return { type: "region", id: region.id, status: 200, html: cached.html, cached: true };
402
+ return { type: "region", id: region.id, status: 200, html: cached.html, cached: true, cacheStatus: "hit" };
352
403
  }
353
404
  if (cached) {
354
405
  revalidateRegionInBackground(page, region, req, key);
@@ -464,6 +515,26 @@ const server = http.createServer(async (req, res) => {
464
515
  }
465
516
  return;
466
517
  }
518
+ // ISR background refresh endpoint (called by the Go server on each route's
519
+ // revalidation cadence). Unlike /__krate/ssr/revalidate this is
520
+ // non-destructive: it re-renders every cached variant in place, so cached
521
+ // dynamic variants stay fresh instead of being evicted (which would make the
522
+ // next request a MISS rather than a HIT).
523
+ if (route === "/__krate/ssr/refresh" && req.method === "POST") {
524
+ const body = await parseBody(req);
525
+ try {
526
+ const { route: targetRoute } = JSON.parse(body);
527
+ const page = findPage(targetRoute);
528
+ const refreshed = page && page.mode === "isr" ? await refreshRouteVariants(page) : 0;
529
+ res.writeHead(200, { "Content-Type": "application/json" });
530
+ res.end(JSON.stringify({ ok: true, refreshed }));
531
+ }
532
+ catch (err) {
533
+ res.writeHead(500, { "Content-Type": "application/json" });
534
+ res.end(JSON.stringify({ error: err.message }));
535
+ }
536
+ return;
537
+ }
467
538
  // Module cache invalidation (called on file change in dev mode)
468
539
  if (route === "/__krate/ssr/invalidate" && req.method === "POST") {
469
540
  const body = await parseBody(req);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krate/runtime",
3
- "version": "0.3.0",
3
+ "version": "0.4.0-beta.2",
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",
@@ -56,7 +56,7 @@
56
56
  ],
57
57
  "devDependencies": {
58
58
  "@types/node": "^26.2.0",
59
- "esbuild": "^0.25.0",
59
+ "esbuild": "^0.28.0",
60
60
  "typescript": "^5.5.0"
61
61
  },
62
62
  "scripts": {