@krate/runtime 0.1.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jsx-types.d.ts +12 -2
- package/dist/krate-runtime.js +1 -1
- package/dist/server.d.ts +4 -0
- package/dist/server.js +7 -0
- package/package.json +1 -1
package/dist/jsx-types.d.ts
CHANGED
|
@@ -164,7 +164,8 @@ declare global {
|
|
|
164
164
|
interface DOMAttributes {
|
|
165
165
|
children?: unknown[] | unknown;
|
|
166
166
|
key?: string | number;
|
|
167
|
-
ref
|
|
167
|
+
/** Assigns the mounted DOM element. Pass a mutable holder (`ref={myRef}`) or a callback (`ref={el => ...}`). */
|
|
168
|
+
ref?: ((el: Element) => void) | Element | null;
|
|
168
169
|
slot?: string;
|
|
169
170
|
style?: CSSProperties | string;
|
|
170
171
|
part?: string;
|
|
@@ -320,6 +321,8 @@ declare global {
|
|
|
320
321
|
useMap?: string;
|
|
321
322
|
width?: number | string;
|
|
322
323
|
fetchPriority?: 'high' | 'low' | 'auto';
|
|
324
|
+
onLoad?: EventHandler<Event>;
|
|
325
|
+
onError?: EventHandler<Event>;
|
|
323
326
|
}
|
|
324
327
|
interface InputHTMLAttributes extends Omit<HTMLAttributes, 'onChange' | 'onInput'> {
|
|
325
328
|
accept?: string;
|
|
@@ -415,6 +418,7 @@ declare global {
|
|
|
415
418
|
name?: string;
|
|
416
419
|
popovertarget?: string;
|
|
417
420
|
popovertargetaction?: 'toggle' | 'show' | 'hide';
|
|
421
|
+
required?: boolean | string;
|
|
418
422
|
type?: 'submit' | 'reset' | 'button';
|
|
419
423
|
value?: string;
|
|
420
424
|
onClick?: (event: MouseEvent & {
|
|
@@ -607,7 +611,7 @@ declare global {
|
|
|
607
611
|
interface SVGAttributes extends AriaAttributes {
|
|
608
612
|
children?: unknown[] | unknown;
|
|
609
613
|
key?: string | number;
|
|
610
|
-
ref?: (el: Element) => void;
|
|
614
|
+
ref?: ((el: Element) => void) | Element | null;
|
|
611
615
|
style?: CSSProperties | string;
|
|
612
616
|
class?: string;
|
|
613
617
|
className?: string;
|
|
@@ -969,6 +973,8 @@ declare global {
|
|
|
969
973
|
wbr: HTMLAttributes;
|
|
970
974
|
line: SVGAttributes;
|
|
971
975
|
path: SVGAttributes;
|
|
976
|
+
polyline: SVGAttributes;
|
|
977
|
+
polygon: SVGAttributes;
|
|
972
978
|
circle: SVGAttributes;
|
|
973
979
|
rect: SVGAttributes;
|
|
974
980
|
g: SVGAttributes;
|
|
@@ -1016,6 +1022,10 @@ declare global {
|
|
|
1016
1022
|
fallback?: any;
|
|
1017
1023
|
}): JSX.Element;
|
|
1018
1024
|
function Link(props: JSX.LinkProps): JSX.Element;
|
|
1025
|
+
function SyntaxHighlight(props: {
|
|
1026
|
+
lang?: string;
|
|
1027
|
+
children?: any;
|
|
1028
|
+
}): JSX.Element;
|
|
1019
1029
|
interface HTMLImageElement {
|
|
1020
1030
|
__jsxProps: JSX.ImageProps;
|
|
1021
1031
|
}
|
package/dist/krate-runtime.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var __krate_exports=(()=>{var D=Object.defineProperty,Ue=Object.defineProperties,Ve=Object.getOwnPropertyDescriptor,ze=Object.getOwnPropertyDescriptors,Ke=Object.getOwnPropertyNames,O=Object.getOwnPropertySymbols;var V=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={}))V.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)=>Ue(e,ze(t));var he=(e,t)=>{var n={};for(var r in e)V.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})},je=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ke(t))!V.call(e,o)&&o!==n&&D(e,o,{get:()=>t[o],enumerable:!(r=Ve(t,o))||r.enumerable});return e};var Xe=e=>je(D({},"__esModule",{value:!0}),e);var bt={};We(bt,{Fragment:()=>ot,clearNodes:()=>Ae,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 j=new WeakMap;function Me(e,t){let n=j.get(e);n||(n=[],j.set(e,n)),n.push(t)}function E(e){let t=j.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 Ae(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?(Ae(n,r),X(e,t,r)):X(e,t,null)}function X(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)X(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),Me(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")?Me(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=[],A=new Set;for(let g=0;g<r.length;g++){let d=r[g],p=l(d);A.add(p);let H=o(d,g);H.__k=p,f.push(H)}for(let[g,d]of m)!A.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 A=o(r[f],f);f<c.length?c[f]!==A&&(E(c[f]),e.replaceChild(A,c[f])):e.insertBefore(A,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,A=()=>{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=A();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 A(){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(M=>{let L=M.getAttribute("href");L&&de.add(L)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(M=>{let L=M.getAttribute("href");L&&!de.has(L)&&M.remove()});let ge=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(M=>{ge.add(M.href)}),ce.forEach(M=>{let L=M.getAttribute("href");if(L&&!ge.has(L)){let U=document.createElement("link");U.rel="stylesheet",U.href=L,document.head.appendChild(U)}}),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 M=P.keys().next().value;M!==void 0&&P.delete(M)}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),A(),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 Xe(bt);})();
|
|
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);})();
|
|
2
2
|
for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
|
package/dist/server.d.ts
CHANGED
|
@@ -54,6 +54,10 @@ export declare function Icon(_props: {
|
|
|
54
54
|
name?: string;
|
|
55
55
|
[key: string]: any;
|
|
56
56
|
}): JSXNode;
|
|
57
|
+
export declare function SyntaxHighlight(props: {
|
|
58
|
+
lang?: string;
|
|
59
|
+
children?: any;
|
|
60
|
+
}): JSXNode;
|
|
57
61
|
export interface GetServerSidePropsContext {
|
|
58
62
|
params?: Record<string, string>;
|
|
59
63
|
query?: Record<string, string>;
|
package/dist/server.js
CHANGED
|
@@ -212,3 +212,10 @@ export function Image(props) {
|
|
|
212
212
|
export function Icon(_props) {
|
|
213
213
|
return raw("<span></span>");
|
|
214
214
|
}
|
|
215
|
+
// SyntaxHighlight — renders a <pre><code> block (Go compiler handles chroma highlighting at build time).
|
|
216
|
+
export function SyntaxHighlight(props) {
|
|
217
|
+
const lang = props.lang || "";
|
|
218
|
+
const code = props.children != null ? String(props.children) : "";
|
|
219
|
+
const cls = lang ? `chroma language-${lang}` : "chroma";
|
|
220
|
+
return raw(`<pre class="chroma"><code class="${escapeHTML(cls)}">${escapeHTML(code)}</code></pre>`);
|
|
221
|
+
}
|