@krate/runtime 0.4.0-beta.4 → 0.4.0-beta.6
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/class-helpers.d.ts +40 -0
- package/dist/class-helpers.js +211 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/krate-hydrate.js +1 -1
- package/dist/krate-runtime.js +1 -1
- package/dist/server-renderer.js +27 -2
- package/dist/signal.d.ts +8 -0
- package/dist/signal.js +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type ClassValue = string | number | boolean | null | undefined | ClassValue[] | Record<string, unknown>;
|
|
2
|
+
/** `clsx` — conditional class names from strings, arrays, and objects. */
|
|
3
|
+
export declare function clsx(...inputs: ClassValue[]): string;
|
|
4
|
+
/**
|
|
5
|
+
* Merge conflicting Tailwind utilities. This is a deliberately small subset:
|
|
6
|
+
* later classes win over earlier ones for the same property prefix. Full
|
|
7
|
+
* `tailwind-merge` semantics (variant/modifier aware) are out of scope; the
|
|
8
|
+
* compiler folds literal calls and this covers dynamic joins.
|
|
9
|
+
*/
|
|
10
|
+
export declare function twMerge(...inputs: ClassValue[]): string;
|
|
11
|
+
/** `cn` — `twMerge` over `clsx`, the shadcn/ui convention. */
|
|
12
|
+
export declare function cn(...inputs: ClassValue[]): string;
|
|
13
|
+
export interface CVAConfig {
|
|
14
|
+
variants?: Record<string, Record<string, string>>;
|
|
15
|
+
defaultVariants?: Record<string, string | null>;
|
|
16
|
+
compoundVariants?: Array<Record<string, unknown>>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* `class-variance-authority` subset. Returns a function that, given a variant
|
|
20
|
+
* selection, produces a class string.
|
|
21
|
+
*/
|
|
22
|
+
export declare function cva(base: string, config?: CVAConfig): (props?: Record<string, unknown>) => string;
|
|
23
|
+
/**
|
|
24
|
+
* `Slot` — renders its single child element instead of wrapping it, merging the
|
|
25
|
+
* Slot's own props onto that child. This is the `asChild` mechanic from
|
|
26
|
+
* shadcn/radix: `<Slot className="x"><a /></Slot>` returns the `<a>` with `x`
|
|
27
|
+
* merged onto it.
|
|
28
|
+
*
|
|
29
|
+
* In Krate's DOM-node JSX model the child is already a built node, so this
|
|
30
|
+
* applies the remaining props (minus `children`) to it and returns it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function Slot(props: Record<string, unknown> & {
|
|
33
|
+
children?: unknown;
|
|
34
|
+
}): Node | null;
|
|
35
|
+
/**
|
|
36
|
+
* `cloneElement` — apply extra props (and optional replacement children) to an
|
|
37
|
+
* existing node and return it. Used by `Slot`/`asChild` and by libraries that
|
|
38
|
+
* clone a single child.
|
|
39
|
+
*/
|
|
40
|
+
export declare function cloneElement(element: Node, props?: Record<string, unknown> | null, ...children: unknown[]): Node;
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// Class-name and slot helpers used by shadcn/ui-style components. These are
|
|
2
|
+
// small, pure, dependency-free implementations of the common `clsx`, `cn`,
|
|
3
|
+
// `cva`, and `Slot`/`asChild` APIs so copied components work without pulling in
|
|
4
|
+
// those npm packages. The compiler folds literal calls at build time; these
|
|
5
|
+
// runtime versions cover dynamic cases.
|
|
6
|
+
/** Flatten a clsx-style value into an array of class tokens. */
|
|
7
|
+
function flattenClass(value, out) {
|
|
8
|
+
if (value == null || value === false || value === true || value === '')
|
|
9
|
+
return;
|
|
10
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
11
|
+
out.push(String(value));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (Array.isArray(value)) {
|
|
15
|
+
for (const item of value)
|
|
16
|
+
flattenClass(item, out);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (typeof value === 'object') {
|
|
20
|
+
for (const key of Object.keys(value)) {
|
|
21
|
+
if (value[key])
|
|
22
|
+
out.push(key);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** `clsx` — conditional class names from strings, arrays, and objects. */
|
|
27
|
+
export function clsx(...inputs) {
|
|
28
|
+
const out = [];
|
|
29
|
+
for (const input of inputs)
|
|
30
|
+
flattenClass(input, out);
|
|
31
|
+
return out.join(' ');
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Merge conflicting Tailwind utilities. This is a deliberately small subset:
|
|
35
|
+
* later classes win over earlier ones for the same property prefix. Full
|
|
36
|
+
* `tailwind-merge` semantics (variant/modifier aware) are out of scope; the
|
|
37
|
+
* compiler folds literal calls and this covers dynamic joins.
|
|
38
|
+
*/
|
|
39
|
+
export function twMerge(...inputs) {
|
|
40
|
+
const tokens = [];
|
|
41
|
+
for (const input of inputs)
|
|
42
|
+
flattenClass(input, tokens);
|
|
43
|
+
const byProperty = new Map();
|
|
44
|
+
const order = [];
|
|
45
|
+
for (const token of tokens) {
|
|
46
|
+
const key = tailwindPropertyKey(token);
|
|
47
|
+
if (!byProperty.has(key))
|
|
48
|
+
order.push(key);
|
|
49
|
+
byProperty.set(key, token);
|
|
50
|
+
}
|
|
51
|
+
return order.map((k) => byProperty.get(k)).join(' ');
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Best-effort property key for a Tailwind class: the leading property/utility
|
|
55
|
+
* segment before a size/colour value, so `px-2` and `px-4` collide but
|
|
56
|
+
* `px-2` and `py-2` do not.
|
|
57
|
+
*/
|
|
58
|
+
function tailwindPropertyKey(token) {
|
|
59
|
+
let t = token;
|
|
60
|
+
let prefix = '';
|
|
61
|
+
// Strip a variant chain (hover:, md:, focus: — anything before the last `:`).
|
|
62
|
+
const colon = t.lastIndexOf(':');
|
|
63
|
+
if (colon >= 0) {
|
|
64
|
+
prefix = t.slice(0, colon + 1);
|
|
65
|
+
t = t.slice(colon + 1);
|
|
66
|
+
}
|
|
67
|
+
const dash = t.indexOf('-');
|
|
68
|
+
const base = dash >= 0 ? t.slice(0, dash) : t;
|
|
69
|
+
const scale = dash >= 0 ? t.slice(dash + 1, dash + 2) : '';
|
|
70
|
+
return prefix + base + (scale && /[0-9]/.test(scale) ? '-' + scale : '');
|
|
71
|
+
}
|
|
72
|
+
/** `cn` — `twMerge` over `clsx`, the shadcn/ui convention. */
|
|
73
|
+
export function cn(...inputs) {
|
|
74
|
+
return twMerge(clsx(...inputs));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* `class-variance-authority` subset. Returns a function that, given a variant
|
|
78
|
+
* selection, produces a class string.
|
|
79
|
+
*/
|
|
80
|
+
export function cva(base, config) {
|
|
81
|
+
const variants = config?.variants ?? {};
|
|
82
|
+
const defaults = config?.defaultVariants ?? {};
|
|
83
|
+
return (props) => {
|
|
84
|
+
const selection = {};
|
|
85
|
+
for (const name of Object.keys(variants)) {
|
|
86
|
+
const chosen = props?.[name] ?? defaults[name];
|
|
87
|
+
if (chosen != null)
|
|
88
|
+
selection[name] = String(chosen);
|
|
89
|
+
}
|
|
90
|
+
const parts = [base];
|
|
91
|
+
for (const name of Object.keys(variants)) {
|
|
92
|
+
const variant = selection[name];
|
|
93
|
+
if (variant && variants[name][variant])
|
|
94
|
+
parts.push(variants[name][variant]);
|
|
95
|
+
}
|
|
96
|
+
for (const compound of config?.compoundVariants ?? []) {
|
|
97
|
+
if (matchesCompound(compound, selection, defaults)) {
|
|
98
|
+
const cls = compound['class'];
|
|
99
|
+
if (typeof cls === 'string')
|
|
100
|
+
parts.push(cls);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const className = props?.['class'] ?? props?.['className'];
|
|
104
|
+
if (typeof className === 'string')
|
|
105
|
+
parts.push(className);
|
|
106
|
+
return twMerge(clsx(parts));
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function matchesCompound(compound, selection, defaults) {
|
|
110
|
+
for (const key of Object.keys(compound)) {
|
|
111
|
+
if (key === 'class')
|
|
112
|
+
continue;
|
|
113
|
+
const want = compound[key];
|
|
114
|
+
const got = selection[key] ?? defaults[key] ?? undefined;
|
|
115
|
+
if (Array.isArray(want)) {
|
|
116
|
+
if (!want.includes(got))
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
else if (want !== got) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* `Slot` — renders its single child element instead of wrapping it, merging the
|
|
127
|
+
* Slot's own props onto that child. This is the `asChild` mechanic from
|
|
128
|
+
* shadcn/radix: `<Slot className="x"><a /></Slot>` returns the `<a>` with `x`
|
|
129
|
+
* merged onto it.
|
|
130
|
+
*
|
|
131
|
+
* In Krate's DOM-node JSX model the child is already a built node, so this
|
|
132
|
+
* applies the remaining props (minus `children`) to it and returns it.
|
|
133
|
+
*/
|
|
134
|
+
export function Slot(props) {
|
|
135
|
+
const child = firstNode(props?.children);
|
|
136
|
+
if (!child)
|
|
137
|
+
return null;
|
|
138
|
+
applySlotProps(child, props);
|
|
139
|
+
return child;
|
|
140
|
+
}
|
|
141
|
+
function firstNode(children) {
|
|
142
|
+
if (children == null)
|
|
143
|
+
return null;
|
|
144
|
+
if (Array.isArray(children)) {
|
|
145
|
+
for (const c of children) {
|
|
146
|
+
const n = firstNode(c);
|
|
147
|
+
if (n)
|
|
148
|
+
return n;
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
if (children instanceof Node)
|
|
153
|
+
return children;
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
function applySlotProps(node, props) {
|
|
157
|
+
if (!(node instanceof Element))
|
|
158
|
+
return;
|
|
159
|
+
for (const key of Object.keys(props)) {
|
|
160
|
+
if (key === 'children' || key === 'ref')
|
|
161
|
+
continue;
|
|
162
|
+
const value = props[key];
|
|
163
|
+
if (value == null || value === false)
|
|
164
|
+
continue;
|
|
165
|
+
if (key === 'class' || key === 'className') {
|
|
166
|
+
const existing = node.getAttribute('class');
|
|
167
|
+
const merged = existing ? existing + ' ' + String(value) : String(value);
|
|
168
|
+
node.setAttribute('class', merged);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (key === 'style' && typeof value === 'object') {
|
|
172
|
+
for (const [prop, val] of Object.entries(value)) {
|
|
173
|
+
node.style.setProperty(kebab(prop), String(val));
|
|
174
|
+
}
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (key.startsWith('on') && typeof value === 'function') {
|
|
178
|
+
node[key] = value;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (value === true) {
|
|
182
|
+
node.setAttribute(key, '');
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
node.setAttribute(key, String(value));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function kebab(name) {
|
|
189
|
+
return name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* `cloneElement` — apply extra props (and optional replacement children) to an
|
|
193
|
+
* existing node and return it. Used by `Slot`/`asChild` and by libraries that
|
|
194
|
+
* clone a single child.
|
|
195
|
+
*/
|
|
196
|
+
export function cloneElement(element, props, ...children) {
|
|
197
|
+
if (!(element instanceof Node))
|
|
198
|
+
return element;
|
|
199
|
+
if (props)
|
|
200
|
+
applySlotProps(element, props);
|
|
201
|
+
if (children.length > 0 && element instanceof Element) {
|
|
202
|
+
element.textContent = '';
|
|
203
|
+
for (const child of children) {
|
|
204
|
+
if (child instanceof Node)
|
|
205
|
+
element.appendChild(child);
|
|
206
|
+
else if (child != null)
|
|
207
|
+
element.appendChild(document.createTextNode(String(child)));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return element;
|
|
211
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export { createSignal, createCSSChoice, createCSSToggle, createCSSFlags, createCSSGroup, createCSSRange, createCSSStack, createEffect, createMemo, onCleanup, onMount, forwardRef, useRef, disposeAll } from './signal.js';
|
|
1
|
+
export { createSignal, createReducer, createCSSChoice, createCSSToggle, createCSSFlags, createCSSGroup, createCSSRange, createCSSStack, createEffect, createMemo, onCleanup, onMount, forwardRef, useRef, disposeAll } from './signal.js';
|
|
2
2
|
export type { CSSARIAOptions, CSSVars, CSSPrimitiveOptions, CSSStackActions } from './signal.js';
|
|
3
3
|
export { h, mount, hydrate, insert, clearNodes, disposeNode } from './dom.js';
|
|
4
4
|
export { Fragment, jsx, jsxs } from './jsx-runtime.js';
|
|
5
5
|
export { initRouter, reinitRouter } from './router.js';
|
|
6
|
+
export { clsx, cn, cva, twMerge, Slot, cloneElement } from './class-helpers.js';
|
|
7
|
+
export type { ClassValue, CVAConfig } from './class-helpers.js';
|
|
6
8
|
export { createContext, resetContexts } from './context.js';
|
|
7
9
|
export { createResource } from './resource.js';
|
|
8
10
|
export type { Context } from './context.js';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { createSignal, createCSSChoice, createCSSToggle, createCSSFlags, createCSSGroup, createCSSRange, createCSSStack, createEffect, createMemo, onCleanup, onMount, forwardRef, useRef, disposeAll } from './signal.js';
|
|
1
|
+
export { createSignal, createReducer, createCSSChoice, createCSSToggle, createCSSFlags, createCSSGroup, createCSSRange, createCSSStack, createEffect, createMemo, onCleanup, onMount, forwardRef, useRef, disposeAll } from './signal.js';
|
|
2
2
|
export { h, mount, hydrate, insert, clearNodes, disposeNode } from './dom.js';
|
|
3
3
|
export { Fragment, jsx, jsxs } from './jsx-runtime.js';
|
|
4
4
|
export { initRouter, reinitRouter } from './router.js';
|
|
5
|
+
export { clsx, cn, cva, twMerge, Slot, cloneElement } from './class-helpers.js';
|
|
5
6
|
export { createContext, resetContexts } from './context.js';
|
|
6
7
|
export { createResource } from './resource.js';
|
|
7
8
|
import './jsx-types.js';
|
package/dist/krate-hydrate.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var __krate_exports=(()=>{var q=Object.defineProperty,Ve=Object.defineProperties,je=Object.getOwnPropertyDescriptor,Be=Object.getOwnPropertyDescriptors,Ue=Object.getOwnPropertyNames,me=Object.getOwnPropertySymbols;var Te=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable;var ge=(e,t,n)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ye=(e,t)=>{for(var n in t||(t={}))Te.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},be=(e,t)=>Ve(e,Be(t));var Fe=(e,t)=>{for(var n in t)q(e,n,{get:t[n],enumerable:!0})},$e=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ue(t))!Te.call(e,s)&&s!==n&&q(e,s,{get:()=>t[s],enumerable:!(r=je(t,s))||r.enumerable});return e};var ze=e=>$e(q({},"__esModule",{value:!0}),e);var bt={};Fe(bt,{clearNodes:()=>Ne,conditional:()=>mt,createCSSChoice:()=>Ye,createCSSFlags:()=>Qe,createCSSGroup:()=>Je,createCSSRange:()=>Ze,createCSSStack:()=>et,createCSSToggle:()=>Ge,createEffect:()=>w,createMemo:()=>it,createResource:()=>pt,createSignal:()=>N,disposeAll:()=>Xe,disposeNode:()=>A,forwardRef:()=>ct,h:()=>ft,hydrate:()=>dt,initRouter:()=>Re,insert:()=>at,mount:()=>ut,onCleanup:()=>X,onMount:()=>ot,reconcile:()=>ht,reconcileTrees:()=>Z,reinitRouter:()=>yt,useRef:()=>st});var L=[],Se=[],W=!1,_=new Set,F=[],$=[],I=!1;function Ee(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 _)z(e);_.clear();for(let e of F)try{e()}catch(t){}F.length=0,$.length=0,I=!1}function Ye(e,t){return N(e)}function Ge(e,t){return N(e)}function Qe(e,t){let n={};for(let s of e){let[l]=N(!1);n[s]=l}return[n,(s,l)=>{}]}function Je(e,t){return N(e)}function Ze(e,t){return N(e)}function et(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:r=>{},pop:()=>{},clear:()=>{}}]}function N(e){let t=e,n=new Set;return[()=>{let l=L[L.length-1];return l&&!l.disposed&&(n.add(l),l.sources.add(n)),t},l=>{let u=typeof l=="function"?l(t):l;if(u!==t){t=u;let T=Array.from(n);for(let h of T){if(h.disposed){n.delete(h);continue}if(h.running){h.rerun=!0;continue}h.queued||(h.queued=!0,$.push(h))}tt()}}]}function tt(){I||(I=!0,queueMicrotask(nt))}function nt(){I=!1;let e=$.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,D(t),t.rerun&&!t.disposed&&(t.rerun=!1,D(t)))}function D(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=Ee(e);return _.add(t),D(t),()=>{z(t),_.delete(t)}}function X(e){let t=L[L.length-1];t?t.cleanups.push(e):F.push(e)}function ot(e){Se.push(e),W||(W=!0,queueMicrotask(rt))}function rt(){W=!1;let e=Se.splice(0);for(let t of e)t()}function it(e){let[t,n]=N(void 0),r=Ee(()=>{let l=e();n(l)});_.add(r),D(r);let s=L[L.length-1];return s&&s.cleanups.push(()=>{r.disposed||(z(r),_.delete(r))}),t}function st(e){return{current:e}}function ct(e){return t=>e(t,t.ref||(()=>{}))}var Y=new WeakMap;function xe(e,t){let n=Y.get(e);n||(n=[],Y.set(e,n)),n.push(t)}function A(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++)A(e.childNodes[n])}function lt(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function Ne(e,t){let n=e.parentNode;if(!n)return;let r=e.nextSibling;for(;r&&r!==t;){let s=r.nextSibling;A(r),n.removeChild(r),r=s}}function at(e,t,n){let r=lt(n);r?(Ne(n,r),G(e,t,r)):G(e,t,null)}function G(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)G(e,r,n)}}function ve(e,t,n){if(t==="class"||t==="className")n===!1||n===null||n===void 0?e.className="":e.className=String(n);else if(t==="style")typeof n=="string"?e.setAttribute("style",n):n&&typeof n=="object"&&Object.assign(e.style,n);else if(t.startsWith("on")&&typeof n=="function"){let r=t.slice(2).toLowerCase(),s=`__krate_${r}`,l=e[s];l&&e.removeEventListener(r,l),e.addEventListener(r,n),e[s]=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),xe(n,w(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function ft(e,t,...n){if(typeof e=="function")return e(be(ye({},t||{}),{children:n}));let r=document.createElement(e);if(t)for(let[s,l]of Object.entries(t))typeof l=="function"&&!s.startsWith("on")?xe(r,w(()=>ve(r,s,l()))):ve(r,s,l);for(let s of n)Ae(r,s);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 ut(e,t){let n=ke(t),r=!1;w(()=>{r||(r=!0,n.appendChild(e()))})}function dt(e,t){let n=ke(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&A(r)}function pt(e,t){let[n,r]=N(void 0),[s,l]=N(!0),[u,T]=N(void 0),[h,m]=N("unresolved"),[E,d]=N(0),a,g=()=>typeof e=="function"?e():e,b=async()=>{a&&a.abort(),a=new AbortController;let k=a,K=g();m(E()>0?"refreshing":"loading"),l(!0),T(void 0);try{let C=await t(K,{signal:k.signal});k.signal.aborted||(r(()=>C),m("ready"))}catch(C){(C==null?void 0:C.name)!=="AbortError"&&!k.signal.aborted&&(T(C),m("error"))}finally{k.signal.aborted||l(!1)}};w(()=>{typeof e=="function"&&e.length===0&&e(),E(),b(),X(()=>{a&&(a.abort(),a=void 0)})});let y=function(){return n()};return Object.defineProperties(y,{loading:{get:()=>s()},error:{get:()=>u()},state:{get:()=>h()}}),[y,{mutate:k=>{r(k)},refetch:()=>{d(k=>k+1)}}]}function ht(e,t,n,r,s,l){let u=[],T=t.nextSibling;for(;T&&T!==n;)u.push(T),T=T.nextSibling;if(l){let h=new Map;for(let d of u){let a=d.__k;a!=null&&h.set(a,d)}let m=[],E=new Set;for(let d=0;d<r.length;d++){let a=r[d],g=l(a);E.add(g);let b=s(a,d);b.__k=g,m.push(b)}for(let[d,a]of h)!E.has(d)&&a.parentNode===e&&(A(a),e.removeChild(a));for(let d=0;d<m.length;d++){let a=m[d],g=d===0?t:m[d-1];a!==g.nextSibling&&e.insertBefore(a,g.nextSibling)}}else{let h=Math.max(u.length,r.length);for(let m=0;m<h;m++)if(m<r.length){let E=s(r[m],m);m<u.length?u[m]!==E&&(A(u[m]),e.replaceChild(E,u[m])):e.insertBefore(E,n)}else m<u.length&&u[m].parentNode===e&&(A(u[m]),e.removeChild(u[m]))}}function mt(e,t,n,r,s,l){let u=null;w(()=>{let h=r()?s():l?l():null;u?h?(A(u),e.replaceChild(h,u)):(A(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 Ce(e,t){let n=new Set;for(let r=0;r<t.attributes.length;r++){let s=t.attributes[r].name,l=t.attributes[r].value;n.add(s),e.getAttribute(s)!==l&&e.setAttribute(s,l)}for(let r=0;r<e.attributes.length;r++){let s=e.attributes[r].name;n.has(s)||e.removeAttribute(s)}}function Q(e,t){let n=document.importNode(t,!0);return e.parentNode&&(A(e),e.parentNode.replaceChild(n,e)),n}function we(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!0}function J(e,t){if(!we(e,t))return Q(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?Q(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,r=t;return P(n)!==P(r)?Q(n,r):(Ce(n,r),Le(n,r),n)}function Le(e,t){let n=Array.from(e.childNodes),r=Array.from(t.childNodes);if(n.length===r.length){let d=!0;for(let a=0;a<r.length;a++)if(P(n[a])!==P(r[a])){d=!1;break}if(d){for(let a=0;a<r.length;a++)J(n[a],r[a]);return}}let s=new Map,l=[];n.forEach((d,a)=>{let g=P(d);g!=null?s.has(g)||s.set(g,a):l.push(a)});let u=new Set,T=0,h=null,m=0,E=()=>{for(;m<l.length&&u.has(l[m]);)m++;return m<l.length?l[m]:-1};for(let d of r){let a=P(d),g;if(a!=null&&s.has(a)){let b=s.get(a);s.delete(a),u.add(b);let y=n[b];b<T?e.insertBefore(y,h):T=b,g=J(y,d)}else if(a==null){let b=E();if(b>=0&&we(n[b],d)){u.add(b);let y=n[b];y.parentNode===e&&y.nextSibling!==h&&e.insertBefore(y,h),g=J(y,d)}else g=document.importNode(d,!0),e.insertBefore(g,h)}else g=document.importNode(d,!0),e.insertBefore(g,h);h=g.nextSibling}n.forEach((d,a)=>{!u.has(a)&&d.parentNode===e&&(A(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 s=document.importNode(t,!0);n.parentNode&&n.parentNode.replaceChild(s,n);return}Ce(n,r),Le(n,r)}var ee=!1,H,V=null,M=new Map,gt=30,O=new Map,Tt=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,s=null,l=new Map,u=null;function T(o){for(let i of e.split(", ")){let c=o.querySelector(i.trim());if(c)return c}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>=gt){let c=M.keys().next().value;c!==void 0&&M.delete(c)}M.set(o,i)}}).catch(()=>{})}function E(){document.addEventListener("mouseover",g),document.addEventListener("focusin",g),typeof IntersectionObserver!="undefined"&&(u=new IntersectionObserver(o=>{for(let i of o)if(i.isIntersecting){let c=i.target,f=c.getAttribute("href");if(f&&h(c)){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 a(){document.removeEventListener("mouseover",g),document.removeEventListener("focusin",g);for(let o of l.values())clearTimeout(o);l.clear(),u&&(u.disconnect(),u=null)}function g(o){let i=o.target.closest("a[data-prefetch]");if(!i||!h(i))return;let c=i.getAttribute("href");if(!c)return;let f=new URL(c,location.origin).href;if(M.has(f))return;let p=l.get(i);p&&clearTimeout(p);let S=setTimeout(()=>{l.delete(i),m(f)},n);l.set(i,S)}function b(o){let i=document.createTreeWalker(o,NodeFilter.SHOW_ELEMENT),c=i.nextNode();for(;c;){let f=c;for(let p of Object.keys(f))p.indexOf("__krate_")===0&&delete f[p];c=i.nextNode()}}let y=null;function te(){let o=T(document),i=document.querySelector("template[data-krate-loading]");i&&i.content&&o&&(y=i.content.cloneNode(!0),document.body.appendChild(y)),o&&(o.style.transition=`opacity ${t}ms ease`,o.style.opacity="0")}function k(){y&&y.parentNode&&y.parentNode.removeChild(y),y=null;let o=T(document);o&&(o.style.opacity="1")}function K(o){try{let i=globalThis.__krate_onNavigation;typeof i=="function"&&i(o)}catch(i){}}function C(o,i,c,f={}){let{replace:p=!1,scroll:S=!0,restoreScroll:R=!1}=f,j=new DOMParser().parseFromString(o,"text/html"),fe=T(j),B=T(document);if(!fe||!B){location.href=i;return}let ue=j.querySelector("title");ue&&(document.title=ue.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),b(B),Z(B,fe);let de=j.querySelectorAll('link[rel="stylesheet"]'),pe=new Set;de.forEach(v=>{let x=v.getAttribute("href");x&&pe.add(x)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(v=>{let x=v.getAttribute("href");x&&!pe.has(x)&&v.remove()});let he=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(v=>{he.add(v.href)}),de.forEach(v=>{let x=v.getAttribute("href");if(x&&!he.has(x)){let U=document.createElement("link");U.rel="stylesheet",U.href=x,document.head.appendChild(U)}}),Pe(c,i).then(()=>{try{Oe(),d()}catch(v){try{let x=globalThis.__krate_onHydrationError;typeof x=="function"&&x(v)}catch(x){}location.href=i}}),k();let De=location.pathname+location.search;if(p)history.replaceState({},"",i);else{if(!R){if(O.size>=Tt){let v=O.keys().next().value;v!==void 0&&O.delete(v)}O.set(De,window.scrollY)}history.pushState({},"",i)}ne(i,{restoreScroll:R,scroll:S}),oe(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:i}})),K(i)}function _e(o){let i=o.indexOf("#");if(i<0||i===o.length-1)return!1;let c=o.slice(i);try{let f=document.querySelector(c);if(f)return f.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch(f){return!1}return!1}function ne(o,i){if(i.restoreScroll){let c=O.get(o);if(c!==void 0){window.scrollTo(0,c);return}}_e(o)||i.scroll&&window.scrollTo(0,0)}function oe(){let o=location.pathname;document.querySelectorAll("a[data-krate-link]").forEach(i=>{let c=i.getAttribute("href");if(!c){i.removeAttribute("aria-current");return}let f=c;try{f=new URL(c,location.origin).pathname}catch(S){return}f===o||o==="/"&&(f===""||f==="/")||f!=="/"&&f.length>1&&o.startsWith(f)?i.setAttribute("aria-current","page"):i.removeAttribute("aria-current")})}function Pe(o,i){return o.length===0?Promise.resolve():Promise.all(o.map(c=>{let f=c.getAttribute("src");return f?He(f,i):Promise.resolve()})).then(()=>{})}function He(o,i){return new Promise(c=>{let f=document.createElement("script"),p=re(o,i);f.src=p,Me.test(p)||f.setAttribute("data-krate-spa",""),f.onload=()=>c(),f.onerror=()=>c(),document.body.appendChild(f)})}function re(o,i){if(/^(https?:)?\/\//.test(o)||o.startsWith("/"))return new URL(o,i).href;let c=i;if(!c.endsWith("/")){let f=c.lastIndexOf("/");c=f>0?c.slice(0,f+1):"/"}return new URL(o,c).href}function Oe(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function Ke(o,i){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",i),K(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 Ie(){return s!==null?Promise.resolve(s):fetch("/500.html",{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>(s=o,o)).catch(()=>null)}function ie(o,i){document.querySelectorAll("script[data-krate-spa]").forEach(p=>p.remove());let c=[],f=new Set;return document.querySelectorAll("script[src]").forEach(p=>{f.add(p.src)}),o.querySelectorAll("script[src]").forEach(p=>{let S=p.getAttribute("src");S&&!f.has(re(S,i))&&c.push(p)}),c}function se(o,i={}){let c=M.get(o);if(c){let S=new DOMParser().parseFromString(c,"text/html");C(c,o,ie(S,o),i);return}te(),H&&H.abort(),H=new AbortController;let f=H.signal;fetch(o,{headers:{Accept:"text/html"},signal:f}).then(p=>p.ok?p.text().then(S=>{let ae=new DOMParser().parseFromString(S,"text/html");C(S,o,ie(ae,o),i)}):(p.status>=500?Ie():qe()).then(R=>{R?Ke(R,o):location.href=o})).catch(p=>{(p==null?void 0:p.name)!=="AbortError"&&(k(),location.href=o)}).finally(()=>{H&&!f.aborted&&(H=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 c=i.getAttribute("href");if(!c)return;let f=new URL(c,location.origin).href,p=i.hasAttribute("data-krate-replace"),S=i.getAttribute("data-krate-scroll")!=="false";if(c===location.pathname+location.search+location.hash){p&&history.replaceState({},"",c),ne(f,{scroll:S});return}se(f,{replace:p,scroll:S})},le=()=>{se(location.href,{restoreScroll:!0})};document.addEventListener("click",ce),window.addEventListener("popstate",le),E(),oe(),document.querySelectorAll("script[src]").forEach(o=>{Me.test(o.src)||o.setAttribute("data-krate-spa","")}),V=()=>{document.removeEventListener("click",ce),window.removeEventListener("popstate",le),a()}}function yt(){V&&(V(),V=null),ee=!1,Re()}return ze(bt);})();
|
|
1
|
+
var __krate_exports=(()=>{var B=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var De=Object.getOwnPropertyNames;var We=Object.prototype.hasOwnProperty;var Be=(e,t)=>{for(var n in t)B(e,n,{get:t[n],enumerable:!0})},Ue=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of De(t))!We.call(e,i)&&i!==n&&B(e,i,{get:()=>t[i],enumerable:!(o=Ie(t,i))||o.enumerable});return e};var Fe=e=>Ue(B({},"__esModule",{value:!0}),e);var At={};Be(At,{Slot:()=>vt,clearNodes:()=>ve,cloneElement:()=>Nt,clsx:()=>ne,cn:()=>St,conditional:()=>gt,createCSSChoice:()=>ze,createCSSFlags:()=>Ye,createCSSGroup:()=>Ge,createCSSRange:()=>Qe,createCSSStack:()=>Ze,createCSSToggle:()=>Xe,createEffect:()=>C,createMemo:()=>ot,createReducer:()=>rt,createResource:()=>dt,createSignal:()=>E,cva:()=>Tt,disposeAll:()=>$e,disposeNode:()=>A,forwardRef:()=>st,h:()=>at,hydrate:()=>ut,initRouter:()=>Re,insert:()=>lt,mount:()=>ft,onCleanup:()=>X,onMount:()=>tt,reconcile:()=>pt,reconcileTrees:()=>J,reinitRouter:()=>yt,twMerge:()=>oe,useRef:()=>it});var w=[],be=[],U=!1,O=new Set,F=[],$=[],V=!1;function Se(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 $e(){for(let e of O)z(e);O.clear();for(let e of F)try{e()}catch{}F.length=0,$.length=0,V=!1}function ze(e,t){return E(e)}function Xe(e,t){return E(e)}function Ye(e,t){let n={};for(let i of e){let[c]=E(!1);n[i]=c}return[n,(i,c)=>{}]}function Ge(e,t){return E(e)}function Qe(e,t){return E(e)}function Ze(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:o=>{},pop:()=>{},clear:()=>{}}]}function E(e){let t=e,n=new Set;return[()=>{let c=w[w.length-1];return c&&!c.disposed&&(n.add(c),c.sources.add(n)),t},c=>{let a=typeof c=="function"?c(t):c;if(a!==t){t=a;let y=Array.from(n);for(let u of y){if(u.disposed){n.delete(u);continue}if(u.running){u.rerun=!0;continue}u.queued||(u.queued=!0,$.push(u))}Je()}}]}function Je(){V||(V=!0,queueMicrotask(et))}function et(){V=!1;let e=$.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,q(t),t.rerun&&!t.disposed&&(t.rerun=!1,q(t)))}function q(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,w.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{w.pop(),e.running=!1}}function C(e){let t=Se(e);return O.add(t),q(t),()=>{z(t),O.delete(t)}}function X(e){let t=w[w.length-1];t?t.cleanups.push(e):F.push(e)}function tt(e){be.push(e),U||(U=!0,queueMicrotask(nt))}function nt(){U=!1;let e=be.splice(0);for(let t of e)t()}function ot(e){let[t,n]=E(void 0),o=Se(()=>{let c=e();n(c)});O.add(o),q(o);let i=w[w.length-1];return i&&i.cleanups.push(()=>{o.disposed||(z(o),O.delete(o))}),t}function rt(e,t){let[n,o]=E(t);return[n,c=>o(a=>e(a,c))]}function it(e){return{current:e}}function st(e){return t=>e(t,t.ref||(()=>{}))}var Y=new WeakMap;function Ee(e,t){let n=Y.get(e);n||(n=[],Y.set(e,n)),n.push(t)}function A(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++)A(e.childNodes[n])}function ct(e){let t=e.nextSibling;for(;t;){if(t.nodeType===8&&t.nodeValue==="k")return t;t=t.nextSibling}return null}function ve(e,t){let n=e.parentNode;if(!n)return;let o=e.nextSibling;for(;o&&o!==t;){let i=o.nextSibling;A(o),n.removeChild(o),o=i}}function lt(e,t,n){let o=ct(n);o?(ve(n,o),G(e,t,o)):G(e,t,null)}function G(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 o of t)G(e,o,n)}}function Te(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 o=t.slice(2).toLowerCase(),i=`__krate_${o}`,c=e[i];c&&e.removeEventListener(o,c),e.addEventListener(o,n),e[i]=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 xe(e,t){if(!(t==null||t===!1||t===!0)){if(Array.isArray(t)){for(let n of t)xe(e,n);return}if(typeof t=="function"){let n=document.createTextNode("");e.appendChild(n),Ee(n,C(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function at(e,t,...n){if(typeof e=="function")return e({...t||{},children:n});let o=document.createElement(e);if(t)for(let[i,c]of Object.entries(t))typeof c=="function"&&!i.startsWith("on")?Ee(o,C(()=>Te(o,i,c()))):Te(o,i,c);for(let i of n)xe(o,i);return o}function Ne(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function ft(e,t){let n=Ne(t),o=!1;C(()=>{o||(o=!0,n.appendChild(e()))})}function ut(e,t){let n=Ne(t);if(n.childNodes.length===0){n.appendChild(e());return}let o=e();o&&A(o)}function dt(e,t){let[n,o]=E(void 0),[i,c]=E(!0),[a,y]=E(void 0),[u,p]=E("unresolved"),[v,g]=E(0),f,m=()=>typeof e=="function"?e():e,S=async()=>{f&&f.abort(),f=new AbortController;let k=f,K=m();p(v()>0?"refreshing":"loading"),c(!0),y(void 0);try{let R=await t(K,{signal:k.signal});k.signal.aborted||(o(()=>R),p("ready"))}catch(R){R?.name!=="AbortError"&&!k.signal.aborted&&(y(R),p("error"))}finally{k.signal.aborted||c(!1)}};C(()=>{typeof e=="function"&&e.length===0&&e(),v(),S(),X(()=>{f&&(f.abort(),f=void 0)})});let b=function(){return n()};return Object.defineProperties(b,{loading:{get:()=>i()},error:{get:()=>a()},state:{get:()=>u()}}),[b,{mutate:k=>{o(k)},refetch:()=>{g(k=>k+1)}}]}function pt(e,t,n,o,i,c){let a=[],y=t.nextSibling;for(;y&&y!==n;)a.push(y),y=y.nextSibling;if(c){let u=new Map;for(let g of a){let f=g.__k;f!=null&&u.set(f,g)}let p=[],v=new Set;for(let g=0;g<o.length;g++){let f=o[g],m=c(f);v.add(m);let S=i(f,g);S.__k=m,p.push(S)}for(let[g,f]of u)!v.has(g)&&f.parentNode===e&&(A(f),e.removeChild(f));for(let g=0;g<p.length;g++){let f=p[g],m=g===0?t:p[g-1];f!==m.nextSibling&&e.insertBefore(f,m.nextSibling)}}else{let u=Math.max(a.length,o.length);for(let p=0;p<u;p++)if(p<o.length){let v=i(o[p],p);p<a.length?a[p]!==v&&(A(a[p]),e.replaceChild(v,a[p])):e.insertBefore(v,n)}else p<a.length&&a[p].parentNode===e&&(A(a[p]),e.removeChild(a[p]))}}function gt(e,t,n,o,i,c){let a=null;C(()=>{let u=o()?i():c?c():null;a?u?(A(a),e.replaceChild(u,a)):(A(a),e.removeChild(a)):u&&e.insertBefore(u,n),a=u})}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 o=t.getAttribute("id");if(o)return"#"+o}return null}function Ae(e,t){let n=new Set;for(let o=0;o<t.attributes.length;o++){let i=t.attributes[o].name,c=t.attributes[o].value;n.add(i),e.getAttribute(i)!==c&&e.setAttribute(i,c)}for(let o=0;o<e.attributes.length;o++){let i=e.attributes[o].name;n.has(i)||e.removeAttribute(i)}}function Q(e,t){let n=document.importNode(t,!0);return e.parentNode&&(A(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 Z(e,t){if(!ke(e,t))return Q(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?Q(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,o=t;return P(n)!==P(o)?Q(n,o):(Ae(n,o),Ce(n,o),n)}function Ce(e,t){let n=Array.from(e.childNodes),o=Array.from(t.childNodes);if(n.length===o.length){let g=!0;for(let f=0;f<o.length;f++)if(P(n[f])!==P(o[f])){g=!1;break}if(g){for(let f=0;f<o.length;f++)Z(n[f],o[f]);return}}let i=new Map,c=[];n.forEach((g,f)=>{let m=P(g);m!=null?i.has(m)||i.set(m,f):c.push(f)});let a=new Set,y=0,u=null,p=0,v=()=>{for(;p<c.length&&a.has(c[p]);)p++;return p<c.length?c[p]:-1};for(let g of o){let f=P(g),m;if(f!=null&&i.has(f)){let S=i.get(f);i.delete(f),a.add(S);let b=n[S];S<y?e.insertBefore(b,u):y=S,m=Z(b,g)}else if(f==null){let S=v();if(S>=0&&ke(n[S],g)){a.add(S);let b=n[S];b.parentNode===e&&b.nextSibling!==u&&e.insertBefore(b,u),m=Z(b,g)}else m=document.importNode(g,!0),e.insertBefore(m,u)}else m=document.importNode(g,!0),e.insertBefore(m,u);u=m.nextSibling}n.forEach((g,f)=>{!a.has(f)&&g.parentNode===e&&(A(g),e.removeChild(g))})}function J(e,t){if(e.nodeType!==Node.ELEMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return;let n=e,o=t;if(n.tagName!==o.tagName){let i=document.importNode(t,!0);n.parentNode&&n.parentNode.replaceChild(i,n);return}Ae(n,o),Ce(n,o)}var ee=!1,_,j=null,L=new Map,ht=30,H=new Map,mt=50,we=/\/chunks\/runtime\.[^/]+\.js$/;function Re(){if(typeof document>"u"||ee)return;ee=!0;let e=".docs-content, main, #root",t=150,n=200,o=null,i=null,c=new Map,a=null;function y(r){for(let s of e.split(", ")){let l=r.querySelector(s.trim());if(l)return l}return r.body}function u(r){if(r.hasAttribute("data-krate-external"))return!1;let s=r.getAttribute("href");return!(!s||s.startsWith("#")||s.startsWith("javascript:")||r.origin!==location.origin||r.target==="_blank")}function p(r){L.has(r)||fetch(r,{headers:{Accept:"text/html"}}).then(s=>s.ok?s.text():null).then(s=>{if(s){if(L.size>=ht){let l=L.keys().next().value;l!==void 0&&L.delete(l)}L.set(r,s)}}).catch(()=>{})}function v(){document.addEventListener("mouseover",m),document.addEventListener("focusin",m),typeof IntersectionObserver<"u"&&(a=new IntersectionObserver(r=>{for(let s of r)if(s.isIntersecting){let l=s.target,d=l.getAttribute("href");if(d&&u(l)){let h=new URL(d,location.origin).href;p(h)}a.unobserve(s.target)}},{rootMargin:"200px"}),g())}function g(){a&&document.querySelectorAll("a[data-prefetch]").forEach(r=>{a.observe(r)})}function f(){document.removeEventListener("mouseover",m),document.removeEventListener("focusin",m);for(let r of c.values())clearTimeout(r);c.clear(),a&&(a.disconnect(),a=null)}function m(r){let s=r.target.closest("a[data-prefetch]");if(!s||!u(s))return;let l=s.getAttribute("href");if(!l)return;let d=new URL(l,location.origin).href;if(L.has(d))return;let h=c.get(s);h&&clearTimeout(h);let T=setTimeout(()=>{c.delete(s),p(d)},n);c.set(s,T)}function S(r){let s=document.createTreeWalker(r,NodeFilter.SHOW_ELEMENT),l=s.nextNode();for(;l;){let d=l;for(let h of Object.keys(d))h.indexOf("__krate_")===0&&delete d[h];l=s.nextNode()}}let b=null;function re(){let r=y(document),s=document.querySelector("template[data-krate-loading]");s&&s.content&&r&&(b=s.content.cloneNode(!0),document.body.appendChild(b)),r&&(r.style.transition=`opacity ${t}ms ease`,r.style.opacity="0")}function k(){b&&b.parentNode&&b.parentNode.removeChild(b),b=null;let r=y(document);r&&(r.style.opacity="1")}function K(r){try{let s=globalThis.__krate_onNavigation;typeof s=="function"&&s(r)}catch{}}function R(r,s,l,d={}){let{replace:h=!1,scroll:T=!0,restoreScroll:M=!1}=d,I=new DOMParser().parseFromString(r,"text/html"),pe=y(I),D=y(document);if(!pe||!D){location.href=s;return}let ge=I.querySelector("title");ge&&(document.title=ge.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),S(D),J(D,pe);let he=I.querySelectorAll('link[rel="stylesheet"]'),me=new Set;he.forEach(x=>{let N=x.getAttribute("href");N&&me.add(N)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(x=>{let N=x.getAttribute("href");N&&!me.has(N)&&x.remove()});let ye=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(x=>{ye.add(x.href)}),he.forEach(x=>{let N=x.getAttribute("href");if(N&&!ye.has(N)){let W=document.createElement("link");W.rel="stylesheet",W.href=N,document.head.appendChild(W)}}),Pe(l,s).then(()=>{try{He(),g()}catch(x){try{let N=globalThis.__krate_onHydrationError;typeof N=="function"&&N(x)}catch{}location.href=s}}),k();let je=location.pathname+location.search;if(h)history.replaceState({},"",s);else{if(!M){if(H.size>=mt){let x=H.keys().next().value;x!==void 0&&H.delete(x)}H.set(je,window.scrollY)}history.pushState({},"",s)}ie(s,{restoreScroll:M,scroll:T}),se(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:s}})),K(s)}function Oe(r){let s=r.indexOf("#");if(s<0||s===r.length-1)return!1;let l=r.slice(s);try{let d=document.querySelector(l);if(d)return d.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch{return!1}return!1}function ie(r,s){if(s.restoreScroll){let l=H.get(r);if(l!==void 0){window.scrollTo(0,l);return}}Oe(r)||s.scroll&&window.scrollTo(0,0)}function se(){let r=location.pathname;document.querySelectorAll("a[data-krate-link]").forEach(s=>{let l=s.getAttribute("href");if(!l){s.removeAttribute("aria-current");return}let d=l;try{d=new URL(l,location.origin).pathname}catch{return}d===r||r==="/"&&(d===""||d==="/")||d!=="/"&&d.length>1&&r.startsWith(d)?s.setAttribute("aria-current","page"):s.removeAttribute("aria-current")})}function Pe(r,s){return r.length===0?Promise.resolve():Promise.all(r.map(l=>{let d=l.getAttribute("src");return d?_e(d,s):Promise.resolve()})).then(()=>{})}function _e(r,s){return new Promise(l=>{let d=document.createElement("script"),h=ce(r,s);d.src=h,we.test(h)||d.setAttribute("data-krate-spa",""),d.onload=()=>l(),d.onerror=()=>l(),document.body.appendChild(d)})}function ce(r,s){if(/^(https?:)?\/\//.test(r)||r.startsWith("/"))return new URL(r,s).href;let l=s;if(!l.endsWith("/")){let d=l.lastIndexOf("/");l=d>0?l.slice(0,d+1):"/"}return new URL(r,l).href}function He(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function Ke(r,s){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",s),K(s),document.open(),document.write(r),document.close()}function Ve(){return o!==null?Promise.resolve(o):fetch("/404.html",{headers:{Accept:"text/html"}}).then(r=>r.ok?r.text():null).then(r=>(o=r,r)).catch(()=>null)}function qe(){return i!==null?Promise.resolve(i):fetch("/500.html",{headers:{Accept:"text/html"}}).then(r=>r.ok?r.text():null).then(r=>(i=r,r)).catch(()=>null)}function le(r,s){document.querySelectorAll("script[data-krate-spa]").forEach(h=>h.remove());let l=[],d=new Set;return document.querySelectorAll("script[src]").forEach(h=>{d.add(h.src)}),r.querySelectorAll("script[src]").forEach(h=>{let T=h.getAttribute("src");T&&!d.has(ce(T,s))&&l.push(h)}),l}function ae(r,s={}){let l=L.get(r);if(l){let T=new DOMParser().parseFromString(l,"text/html");R(l,r,le(T,r),s);return}re(),_&&_.abort(),_=new AbortController;let d=_.signal;fetch(r,{headers:{Accept:"text/html"},signal:d}).then(h=>h.ok?h.text().then(T=>{let de=new DOMParser().parseFromString(T,"text/html");R(T,r,le(de,r),s)}):(h.status>=500?qe():Ve()).then(M=>{M?Ke(M,r):location.href=r})).catch(h=>{h?.name!=="AbortError"&&(k(),location.href=r)}).finally(()=>{_&&!d.aborted&&(_=void 0)})}let fe=r=>{if(r.defaultPrevented||r.button!==0||r.metaKey||r.ctrlKey||r.shiftKey||r.altKey)return;let s=r.target.closest("a[data-krate-link]");if(!s||!u(s))return;r.preventDefault();let l=s.getAttribute("href");if(!l)return;let d=new URL(l,location.origin).href,h=s.hasAttribute("data-krate-replace"),T=s.getAttribute("data-krate-scroll")!=="false";if(l===location.pathname+location.search+location.hash){h&&history.replaceState({},"",l),ie(d,{scroll:T});return}ae(d,{replace:h,scroll:T})},ue=()=>{ae(location.href,{restoreScroll:!0})};document.addEventListener("click",fe),window.addEventListener("popstate",ue),v(),se(),document.querySelectorAll("script[src]").forEach(r=>{we.test(r.src)||r.setAttribute("data-krate-spa","")}),j=()=>{document.removeEventListener("click",fe),window.removeEventListener("popstate",ue),f()}}function yt(){j&&(j(),j=null),ee=!1,Re()}function te(e,t){if(!(e==null||e===!1||e===!0||e==="")){if(typeof e=="string"||typeof e=="number"){t.push(String(e));return}if(Array.isArray(e)){for(let n of e)te(n,t);return}if(typeof e=="object")for(let n of Object.keys(e))e[n]&&t.push(n)}}function ne(...e){let t=[];for(let n of e)te(n,t);return t.join(" ")}function oe(...e){let t=[];for(let i of e)te(i,t);let n=new Map,o=[];for(let i of t){let c=bt(i);n.has(c)||o.push(c),n.set(c,i)}return o.map(i=>n.get(i)).join(" ")}function bt(e){let t=e,n="",o=t.lastIndexOf(":");o>=0&&(n=t.slice(0,o+1),t=t.slice(o+1));let i=t.indexOf("-"),c=i>=0?t.slice(0,i):t,a=i>=0?t.slice(i+1,i+2):"";return n+c+(a&&/[0-9]/.test(a)?"-"+a:"")}function St(...e){return oe(ne(...e))}function Tt(e,t){let n=t?.variants??{},o=t?.defaultVariants??{};return i=>{let c={};for(let u of Object.keys(n)){let p=i?.[u]??o[u];p!=null&&(c[u]=String(p))}let a=[e];for(let u of Object.keys(n)){let p=c[u];p&&n[u][p]&&a.push(n[u][p])}for(let u of t?.compoundVariants??[])if(Et(u,c,o)){let p=u.class;typeof p=="string"&&a.push(p)}let y=i?.class??i?.className;return typeof y=="string"&&a.push(y),oe(ne(a))}}function Et(e,t,n){for(let o of Object.keys(e)){if(o==="class")continue;let i=e[o],c=t[o]??n[o]??void 0;if(Array.isArray(i)){if(!i.includes(c))return!1}else if(i!==c)return!1}return!0}function vt(e){let t=Le(e?.children);return t?(Me(t,e),t):null}function Le(e){if(e==null)return null;if(Array.isArray(e)){for(let t of e){let n=Le(t);if(n)return n}return null}return e instanceof Node?e:null}function Me(e,t){if(e instanceof Element)for(let n of Object.keys(t)){if(n==="children"||n==="ref")continue;let o=t[n];if(!(o==null||o===!1)){if(n==="class"||n==="className"){let i=e.getAttribute("class"),c=i?i+" "+String(o):String(o);e.setAttribute("class",c);continue}if(n==="style"&&typeof o=="object"){for(let[i,c]of Object.entries(o))e.style.setProperty(xt(i),String(c));continue}if(n.startsWith("on")&&typeof o=="function"){e[n]=o;continue}if(o===!0){e.setAttribute(n,"");continue}e.setAttribute(n,String(o))}}}function xt(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function Nt(e,t,...n){if(!(e instanceof Node))return e;if(t&&Me(e,t),n.length>0&&e instanceof Element){e.textContent="";for(let o of n)o instanceof Node?e.appendChild(o):o!=null&&e.appendChild(document.createTextNode(String(o)))}return e}return Fe(At);})();
|
|
2
2
|
for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
|
package/dist/krate-runtime.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var __krate_exports=(()=>{var B=Object.defineProperty,ze=Object.defineProperties,je=Object.getOwnPropertyDescriptor,We=Object.getOwnPropertyDescriptors,Xe=Object.getOwnPropertyNames,D=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(D)for(var n of D(t))ve.call(t,n)&&Te(e,n,t[n]);return e},Ee=(e,t)=>ze(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&&D)for(var r of D(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 Mt={};Ge(Mt,{Fragment:()=>pt,clearNodes:()=>Se,conditional:()=>vt,createCSSChoice:()=>Qe,createCSSFlags:()=>et,createCSSGroup:()=>tt,createCSSRange:()=>nt,createCSSStack:()=>rt,createCSSToggle:()=>Ze,createEffect:()=>k,createMemo:()=>ut,createResource:()=>mt,createSignal:()=>L,disposeAll:()=>$e,disposeNode:()=>y,forwardRef:()=>ct,h:()=>F,hydrate:()=>ft,initRouter:()=>Ie,insert:()=>gt,jsx:()=>we,jsxs:()=>ht,mount:()=>bt,onCleanup:()=>$,onMount:()=>ot,reconcile:()=>Tt,reconcileTrees:()=>ne,reinitRouter:()=>At,useRef:()=>lt});var C=[],Me=[],X=!1,P=new Set,G=[],J=[],K=!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,K=!1}function Qe(e,t){return L(e)}function Ze(e,t){return L(e)}function et(e,t){let n={};for(let o of e){let[u]=L(!1);n[o]=u}return[n,(o,u)=>{}]}function tt(e,t){return L(e)}function nt(e,t){return L(e)}function rt(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:r=>{},pop:()=>{},clear:()=>{}}]}function L(e){let t=e,n=new Set;return[()=>{let u=C[C.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))}it()}}]}function it(){K||(K=!0,queueMicrotask(st))}function st(){K=!1;let e=J.splice(0);for(let t of e)t.disposed||(t.queued=!1,t.rerun=!1,q(t),t.rerun&&!t.disposed&&(t.rerun=!1,q(t)))}function q(e){e.running=!0;for(let t of e.cleanups)t();e.cleanups.length=0,C.push(e);try{let t=e.fn();typeof t=="function"&&e.cleanups.push(t)}finally{C.pop(),e.running=!1}}function k(e){let t=Le(e);return P.add(t),q(t),()=>{Y(t),P.delete(t)}}function $(e){let t=C[C.length-1];t?t.cleanups.push(e):G.push(e)}function ot(e){Me.push(e),X||(X=!0,queueMicrotask(at))}function at(){X=!1;let e=Me.splice(0);for(let t of e)t()}function ut(e){let[t,n]=L(void 0),r=Le(()=>{let u=e();n(u)});P.add(r),q(r);let o=C[C.length-1];return o&&o.cleanups.push(()=>{r.disposed||(Y(r),P.delete(r))}),t}function lt(e){return{current:e}}function ct(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 y(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++)y(e.childNodes[n])}function dt(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;y(r),n.removeChild(r),r=o}}function gt(e,t,n){let r=dt(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,k(()=>{n.nodeValue=String(t())}));return}e.appendChild(t instanceof Node?t:document.createTextNode(String(t)))}}function F(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,k(()=>ye(r,o,u()))):ye(r,o,u);for(let o of n)ke(r,o);return r}function Ce(e){if(typeof e=="string"){let t=document.querySelector(e);if(!t)throw new Error(`Container "${e}" not found`);return t}return e}function bt(e,t){let n=Ce(t),r=!1;k(()=>{r||(r=!0,n.appendChild(e()))})}function ft(e,t){let n=Ce(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&y(r)}function mt(e,t){let[n,r]=L(void 0),[o,u]=L(!0),[d,h]=L(void 0),[f,m]=L("unresolved"),[E,g]=L(0),l,p=()=>typeof e=="function"?e():e,v=async()=>{l&&l.abort(),l=new AbortController;let x=l,_=p();m(E()>0?"refreshing":"loading"),u(!0),h(void 0);try{let S=await t(_,{signal:x.signal});x.signal.aborted||(r(()=>S),m("ready"))}catch(S){(S==null?void 0:S.name)!=="AbortError"&&!x.signal.aborted&&(h(S),m("error"))}finally{x.signal.aborted||u(!1)}};k(()=>{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:x=>{r(x)},refetch:()=>{g(x=>x+1)}}]}function pt(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 we(e,t,n){let r=e;if(!t)return F(r,null);let h=t,{children:o}=h,u=Ae(h,["children"]),d=o!==void 0?Array.isArray(o)?o:[o]:[];return F(r,Object.keys(u).length>0?u:null,...d)}function ht(e,t,n){return we(e,t,n)}function Tt(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&&(y(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&&(y(d[m]),e.replaceChild(E,d[m])):e.insertBefore(E,n)}else m<d.length&&d[m].parentNode===e&&(y(d[m]),e.removeChild(d[m]))}}function vt(e,t,n,r,o,u){let d=null;k(()=>{let f=r()?o():u?u():null;d?f?(y(d),e.replaceChild(f,d)):(y(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&&(y(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&&(y(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,V=null,w=new Map,Ht=30,I=new Map,Et=50,Re=/\/chunks\/runtime\.[^/]+\.js$/;function Ie(){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){w.has(i)||fetch(i,{headers:{Accept:"text/html"}}).then(s=>s.ok?s.text():null).then(s=>{if(s){if(w.size>=Ht){let a=w.keys().next().value;a!==void 0&&w.delete(a)}w.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(w.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 x(){T&&T.parentNode&&T.parentNode.removeChild(T),T=null;let i=h(document);i&&(i.style.opacity="1")}function _(i){try{let s=globalThis.__krate_onNavigation;typeof s=="function"&&s(i)}catch(s){}}function S(i,s,a,c={}){let{replace:b=!1,scroll:H=!0,restoreScroll:N=!1}=c,U=new DOMParser().parseFromString(i,"text/html"),be=h(U),z=h(document);if(!be||!z){location.href=s;return}let fe=U.querySelector("title");fe&&(document.title=fe.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),v(z),ne(z,be);let me=U.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)}}),De(a,s).then(()=>{try{Ke(),g()}catch(A){try{let M=globalThis.__krate_onHydrationError;typeof M=="function"&&M(A)}catch(M){}location.href=s}}),x();let Ue=location.pathname+location.search;if(b)history.replaceState({},"",s);else{if(!N){if(I.size>=Et){let A=I.keys().next().value;A!==void 0&&I.delete(A)}I.set(Ue,window.scrollY)}history.pushState({},"",s)}se(s,{restoreScroll:N,scroll:H}),oe(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:s}})),_(s)}function _e(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=I.get(i);if(a!==void 0){window.scrollTo(0,a);return}}_e(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 De(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 Ke(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function qe(i,s){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",s),_(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 H=b.getAttribute("src");H&&!c.has(ae(H,s))&&a.push(b)}),a}function le(i,s={}){let a=w.get(i);if(a){let H=new DOMParser().parseFromString(a,"text/html");S(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");S(H,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"&&(x(),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","")}),V=()=>{document.removeEventListener("click",ce),window.removeEventListener("popstate",de),l()}}function At(){V&&(V(),V=null),re=!1,Ie()}return Ye(Mt);})();
|
|
1
|
+
var __krate_exports=(()=>{var U=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var Ue=Object.prototype.hasOwnProperty;var ze=(e,t)=>{for(var n in t)U(e,n,{get:t[n],enumerable:!0})},We=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of je(t))!Ue.call(e,s)&&s!==n&&U(e,s,{get:()=>t[s],enumerable:!(r=Fe(t,s))||r.enumerable});return e};var Xe=e=>We(U({},"__esModule",{value:!0}),e);var kt={};ze(kt,{Fragment:()=>bt,Slot:()=>yt,clearNodes:()=>Me,cloneElement:()=>St,clsx:()=>re,cn:()=>At,conditional:()=>ht,createCSSChoice:()=>Je,createCSSFlags:()=>$e,createCSSGroup:()=>Qe,createCSSRange:()=>Ze,createCSSStack:()=>et,createCSSToggle:()=>Ye,createEffect:()=>S,createMemo:()=>st,createReducer:()=>ot,createResource:()=>ft,createSignal:()=>H,cva:()=>Mt,disposeAll:()=>Ge,disposeNode:()=>y,forwardRef:()=>ut,h:()=>V,hydrate:()=>gt,initRouter:()=>Ne,insert:()=>ct,jsx:()=>xe,jsxs:()=>mt,mount:()=>dt,onCleanup:()=>J,onMount:()=>rt,reconcile:()=>pt,reconcileTrees:()=>ee,reinitRouter:()=>Et,twMerge:()=>ie,useRef:()=>at});var k=[],ve=[],z=!1,P=new Set,W=[],X=[],D=!1;function Ee(e){return{fn:e,cleanups:[],disposed:!1,sources:new Set,running:!1,rerun:!1,queued:!1}}function G(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 P)G(e);P.clear();for(let e of W)try{e()}catch{}W.length=0,X.length=0,D=!1}function Je(e,t){return H(e)}function Ye(e,t){return H(e)}function $e(e,t){let n={};for(let s of e){let[a]=H(!1);n[s]=a}return[n,(s,a)=>{}]}function Qe(e,t){return H(e)}function Ze(e,t){return H(e)}function et(e,t){let n=()=>e[0];return[{top:n,peek:n},{push:r=>{},pop:()=>{},clear:()=>{}}]}function H(e){let t=e,n=new Set;return[()=>{let a=k[k.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 h=Array.from(n);for(let d of h){if(d.disposed){n.delete(d);continue}if(d.running){d.rerun=!0;continue}d.queued||(d.queued=!0,X.push(d))}tt()}}]}function tt(){D||(D=!0,queueMicrotask(nt))}function nt(){D=!1;let e=X.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,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=Ee(e);return P.add(t),B(t),()=>{G(t),P.delete(t)}}function J(e){let t=k[k.length-1];t?t.cleanups.push(e):W.push(e)}function rt(e){ve.push(e),z||(z=!0,queueMicrotask(it))}function it(){z=!1;let e=ve.splice(0);for(let t of e)t()}function st(e){let[t,n]=H(void 0),r=Ee(()=>{let a=e();n(a)});P.add(r),B(r);let s=k[k.length-1];return s&&s.cleanups.push(()=>{r.disposed||(G(r),P.delete(r))}),t}function ot(e,t){let[n,r]=H(t);return[n,a=>r(u=>e(u,a))]}function at(e){return{current:e}}function ut(e){return t=>e(t,t.ref||(()=>{}))}var Y=new WeakMap;function Ae(e,t){let n=Y.get(e);n||(n=[],Y.set(e,n)),n.push(t)}function y(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++)y(e.childNodes[n])}function lt(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 s=r.nextSibling;y(r),n.removeChild(r),r=s}}function ct(e,t,n){let r=lt(n);r?(Me(n,r),$(e,t,r)):$(e,t,null)}function $(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)$(e,r,n)}}function He(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(),s=`__krate_${r}`,a=e[s];a&&e.removeEventListener(r,a),e.addEventListener(r,n),e[s]=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 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,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({...t||{},children:n});let r=document.createElement(e);if(t)for(let[s,a]of Object.entries(t))typeof a=="function"&&!s.startsWith("on")?Ae(r,S(()=>He(r,s,a()))):He(r,s,a);for(let s of n)Le(r,s);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 dt(e,t){let n=ye(t),r=!1;S(()=>{r||(r=!0,n.appendChild(e()))})}function gt(e,t){let n=ye(t);if(n.childNodes.length===0){n.appendChild(e());return}let r=e();r&&y(r)}function ft(e,t){let[n,r]=H(void 0),[s,a]=H(!0),[u,h]=H(void 0),[d,f]=H("unresolved"),[A,b]=H(0),c,p=()=>typeof e=="function"?e():e,v=async()=>{c&&c.abort(),c=new AbortController;let x=c,_=p();f(A()>0?"refreshing":"loading"),a(!0),h(void 0);try{let C=await t(_,{signal:x.signal});x.signal.aborted||(r(()=>C),f("ready"))}catch(C){C?.name!=="AbortError"&&!x.signal.aborted&&(h(C),f("error"))}finally{x.signal.aborted||a(!1)}};S(()=>{typeof e=="function"&&e.length===0&&e(),A(),v(),J(()=>{c&&(c.abort(),c=void 0)})});let T=function(){return n()};return Object.defineProperties(T,{loading:{get:()=>s()},error:{get:()=>u()},state:{get:()=>d()}}),[T,{mutate:x=>{r(x)},refetch:()=>{b(x=>x+1)}}]}function bt(e){let t=document.createDocumentFragment(),n=e.children;if(n){let r=Array.isArray(n)?n:[n];for(let s of r)s instanceof Node?t.appendChild(s):t.appendChild(document.createTextNode(String(s)))}return t}function xe(e,t,n){let r=e;if(!t)return V(r,null);let{children:s,...a}=t,u=s!==void 0?Array.isArray(s)?s:[s]:[];return V(r,Object.keys(a).length>0?a:null,...u)}function mt(e,t,n){return xe(e,t,n)}function pt(e,t,n,r,s,a){let u=[],h=t.nextSibling;for(;h&&h!==n;)u.push(h),h=h.nextSibling;if(a){let d=new Map;for(let b of u){let c=b.__k;c!=null&&d.set(c,b)}let f=[],A=new Set;for(let b=0;b<r.length;b++){let c=r[b],p=a(c);A.add(p);let v=s(c,b);v.__k=p,f.push(v)}for(let[b,c]of d)!A.has(b)&&c.parentNode===e&&(y(c),e.removeChild(c));for(let b=0;b<f.length;b++){let c=f[b],p=b===0?t:f[b-1];c!==p.nextSibling&&e.insertBefore(c,p.nextSibling)}}else{let d=Math.max(u.length,r.length);for(let f=0;f<d;f++)if(f<r.length){let A=s(r[f],f);f<u.length?u[f]!==A&&(y(u[f]),e.replaceChild(A,u[f])):e.insertBefore(A,n)}else f<u.length&&u[f].parentNode===e&&(y(u[f]),e.removeChild(u[f]))}}function ht(e,t,n,r,s,a){let u=null;S(()=>{let d=r()?s():a?a():null;u?d?(y(u),e.replaceChild(d,u)):(y(u),e.removeChild(u)):d&&e.insertBefore(d,n),u=d})}function R(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 s=t.attributes[r].name,a=t.attributes[r].value;n.add(s),e.getAttribute(s)!==a&&e.setAttribute(s,a)}for(let r=0;r<e.attributes.length;r++){let s=e.attributes[r].name;n.has(s)||e.removeAttribute(s)}}function Q(e,t){let n=document.importNode(t,!0);return e.parentNode&&(y(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 Z(e,t){if(!ke(e,t))return Q(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?Q(e,t):e;if(e.nodeType!==Node.ELEMENT_NODE)return e;let n=e,r=t;return R(n)!==R(r)?Q(n,r):(Se(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 b=!0;for(let c=0;c<r.length;c++)if(R(n[c])!==R(r[c])){b=!1;break}if(b){for(let c=0;c<r.length;c++)Z(n[c],r[c]);return}}let s=new Map,a=[];n.forEach((b,c)=>{let p=R(b);p!=null?s.has(p)||s.set(p,c):a.push(c)});let u=new Set,h=0,d=null,f=0,A=()=>{for(;f<a.length&&u.has(a[f]);)f++;return f<a.length?a[f]:-1};for(let b of r){let c=R(b),p;if(c!=null&&s.has(c)){let v=s.get(c);s.delete(c),u.add(v);let T=n[v];v<h?e.insertBefore(T,d):h=v,p=Z(T,b)}else if(c==null){let v=A();if(v>=0&&ke(n[v],b)){u.add(v);let T=n[v];T.parentNode===e&&T.nextSibling!==d&&e.insertBefore(T,d),p=Z(T,b)}else p=document.importNode(b,!0),e.insertBefore(p,d)}else p=document.importNode(b,!0),e.insertBefore(p,d);d=p.nextSibling}n.forEach((b,c)=>{!u.has(c)&&b.parentNode===e&&(y(b),e.removeChild(b))})}function ee(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 s=document.importNode(t,!0);n.parentNode&&n.parentNode.replaceChild(s,n);return}Se(n,r),Ce(n,r)}var te=!1,O,K=null,w=new Map,Tt=30,I=new Map,vt=50,we=/\/chunks\/runtime\.[^/]+\.js$/;function Ne(){if(typeof document>"u"||te)return;te=!0;let e=".docs-content, main, #root",t=150,n=200,r=null,s=null,a=new Map,u=null;function h(i){for(let o of e.split(", ")){let l=i.querySelector(o.trim());if(l)return l}return i.body}function d(i){if(i.hasAttribute("data-krate-external"))return!1;let o=i.getAttribute("href");return!(!o||o.startsWith("#")||o.startsWith("javascript:")||i.origin!==location.origin||i.target==="_blank")}function f(i){w.has(i)||fetch(i,{headers:{Accept:"text/html"}}).then(o=>o.ok?o.text():null).then(o=>{if(o){if(w.size>=Tt){let l=w.keys().next().value;l!==void 0&&w.delete(l)}w.set(i,o)}}).catch(()=>{})}function A(){document.addEventListener("mouseover",p),document.addEventListener("focusin",p),typeof IntersectionObserver<"u"&&(u=new IntersectionObserver(i=>{for(let o of i)if(o.isIntersecting){let l=o.target,g=l.getAttribute("href");if(g&&d(l)){let m=new URL(g,location.origin).href;f(m)}u.unobserve(o.target)}},{rootMargin:"200px"}),b())}function b(){u&&document.querySelectorAll("a[data-prefetch]").forEach(i=>{u.observe(i)})}function c(){document.removeEventListener("mouseover",p),document.removeEventListener("focusin",p);for(let i of a.values())clearTimeout(i);a.clear(),u&&(u.disconnect(),u=null)}function p(i){let o=i.target.closest("a[data-prefetch]");if(!o||!d(o))return;let l=o.getAttribute("href");if(!l)return;let g=new URL(l,location.origin).href;if(w.has(g))return;let m=a.get(o);m&&clearTimeout(m);let E=setTimeout(()=>{a.delete(o),f(g)},n);a.set(o,E)}function v(i){let o=document.createTreeWalker(i,NodeFilter.SHOW_ELEMENT),l=o.nextNode();for(;l;){let g=l;for(let m of Object.keys(g))m.indexOf("__krate_")===0&&delete g[m];l=o.nextNode()}}let T=null;function se(){let i=h(document),o=document.querySelector("template[data-krate-loading]");o&&o.content&&i&&(T=o.content.cloneNode(!0),document.body.appendChild(T)),i&&(i.style.transition=`opacity ${t}ms ease`,i.style.opacity="0")}function x(){T&&T.parentNode&&T.parentNode.removeChild(T),T=null;let i=h(document);i&&(i.style.opacity="1")}function _(i){try{let o=globalThis.__krate_onNavigation;typeof o=="function"&&o(i)}catch{}}function C(i,o,l,g={}){let{replace:m=!1,scroll:E=!0,restoreScroll:N=!1}=g,q=new DOMParser().parseFromString(i,"text/html"),be=h(q),F=h(document);if(!be||!F){location.href=o;return}let me=q.querySelector("title");me&&(document.title=me.textContent||""),typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),v(F),ee(F,be);let pe=q.querySelectorAll('link[rel="stylesheet"]'),he=new Set;pe.forEach(M=>{let L=M.getAttribute("href");L&&he.add(L)}),document.querySelectorAll('link[rel="stylesheet"]').forEach(M=>{let L=M.getAttribute("href");L&&!he.has(L)&&M.remove()});let Te=new Set;document.querySelectorAll('link[rel="stylesheet"]').forEach(M=>{Te.add(M.href)}),pe.forEach(M=>{let L=M.getAttribute("href");if(L&&!Te.has(L)){let j=document.createElement("link");j.rel="stylesheet",j.href=L,document.head.appendChild(j)}}),Ie(l,o).then(()=>{try{De(),b()}catch(M){try{let L=globalThis.__krate_onHydrationError;typeof L=="function"&&L(M)}catch{}location.href=o}}),x();let qe=location.pathname+location.search;if(m)history.replaceState({},"",o);else{if(!N){if(I.size>=vt){let M=I.keys().next().value;M!==void 0&&I.delete(M)}I.set(qe,window.scrollY)}history.pushState({},"",o)}oe(o,{restoreScroll:N,scroll:E}),ae(),window.dispatchEvent(new CustomEvent("krate:navigate",{detail:{url:o}})),_(o)}function Oe(i){let o=i.indexOf("#");if(o<0||o===i.length-1)return!1;let l=i.slice(o);try{let g=document.querySelector(l);if(g)return g.scrollIntoView({behavior:"smooth",block:"start"}),!0}catch{return!1}return!1}function oe(i,o){if(o.restoreScroll){let l=I.get(i);if(l!==void 0){window.scrollTo(0,l);return}}Oe(i)||o.scroll&&window.scrollTo(0,0)}function ae(){let i=location.pathname;document.querySelectorAll("a[data-krate-link]").forEach(o=>{let l=o.getAttribute("href");if(!l){o.removeAttribute("aria-current");return}let g=l;try{g=new URL(l,location.origin).pathname}catch{return}g===i||i==="/"&&(g===""||g==="/")||g!=="/"&&g.length>1&&i.startsWith(g)?o.setAttribute("aria-current","page"):o.removeAttribute("aria-current")})}function Ie(i,o){return i.length===0?Promise.resolve():Promise.all(i.map(l=>{let g=l.getAttribute("src");return g?_e(g,o):Promise.resolve()})).then(()=>{})}function _e(i,o){return new Promise(l=>{let g=document.createElement("script"),m=ue(i,o);g.src=m,we.test(m)||g.setAttribute("data-krate-spa",""),g.onload=()=>l(),g.onerror=()=>l(),document.body.appendChild(g)})}function ue(i,o){if(/^(https?:)?\/\//.test(i)||i.startsWith("/"))return new URL(i,o).href;let l=o;if(!l.endsWith("/")){let g=l.lastIndexOf("/");l=g>0?l.slice(0,g+1):"/"}return new URL(i,l).href}function De(){typeof globalThis.__krate_hydrate=="function"&&globalThis.__krate_hydrate()}function Be(i,o){typeof globalThis.disposeAll=="function"&&globalThis.disposeAll(),history.pushState({},"",o),_(o),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 Ke(){return s!==null?Promise.resolve(s):fetch("/500.html",{headers:{Accept:"text/html"}}).then(i=>i.ok?i.text():null).then(i=>(s=i,i)).catch(()=>null)}function le(i,o){document.querySelectorAll("script[data-krate-spa]").forEach(m=>m.remove());let l=[],g=new Set;return document.querySelectorAll("script[src]").forEach(m=>{g.add(m.src)}),i.querySelectorAll("script[src]").forEach(m=>{let E=m.getAttribute("src");E&&!g.has(ue(E,o))&&l.push(m)}),l}function ce(i,o={}){let l=w.get(i);if(l){let E=new DOMParser().parseFromString(l,"text/html");C(l,i,le(E,i),o);return}se(),O&&O.abort(),O=new AbortController;let g=O.signal;fetch(i,{headers:{Accept:"text/html"},signal:g}).then(m=>m.ok?m.text().then(E=>{let fe=new DOMParser().parseFromString(E,"text/html");C(E,i,le(fe,i),o)}):(m.status>=500?Ke():Ve()).then(N=>{N?Be(N,i):location.href=i})).catch(m=>{m?.name!=="AbortError"&&(x(),location.href=i)}).finally(()=>{O&&!g.aborted&&(O=void 0)})}let de=i=>{if(i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey)return;let o=i.target.closest("a[data-krate-link]");if(!o||!d(o))return;i.preventDefault();let l=o.getAttribute("href");if(!l)return;let g=new URL(l,location.origin).href,m=o.hasAttribute("data-krate-replace"),E=o.getAttribute("data-krate-scroll")!=="false";if(l===location.pathname+location.search+location.hash){m&&history.replaceState({},"",l),oe(g,{scroll:E});return}ce(g,{replace:m,scroll:E})},ge=()=>{ce(location.href,{restoreScroll:!0})};document.addEventListener("click",de),window.addEventListener("popstate",ge),A(),ae(),document.querySelectorAll("script[src]").forEach(i=>{we.test(i.src)||i.setAttribute("data-krate-spa","")}),K=()=>{document.removeEventListener("click",de),window.removeEventListener("popstate",ge),c()}}function Et(){K&&(K(),K=null),te=!1,Ne()}function ne(e,t){if(!(e==null||e===!1||e===!0||e==="")){if(typeof e=="string"||typeof e=="number"){t.push(String(e));return}if(Array.isArray(e)){for(let n of e)ne(n,t);return}if(typeof e=="object")for(let n of Object.keys(e))e[n]&&t.push(n)}}function re(...e){let t=[];for(let n of e)ne(n,t);return t.join(" ")}function ie(...e){let t=[];for(let s of e)ne(s,t);let n=new Map,r=[];for(let s of t){let a=Ht(s);n.has(a)||r.push(a),n.set(a,s)}return r.map(s=>n.get(s)).join(" ")}function Ht(e){let t=e,n="",r=t.lastIndexOf(":");r>=0&&(n=t.slice(0,r+1),t=t.slice(r+1));let s=t.indexOf("-"),a=s>=0?t.slice(0,s):t,u=s>=0?t.slice(s+1,s+2):"";return n+a+(u&&/[0-9]/.test(u)?"-"+u:"")}function At(...e){return ie(re(...e))}function Mt(e,t){let n=t?.variants??{},r=t?.defaultVariants??{};return s=>{let a={};for(let d of Object.keys(n)){let f=s?.[d]??r[d];f!=null&&(a[d]=String(f))}let u=[e];for(let d of Object.keys(n)){let f=a[d];f&&n[d][f]&&u.push(n[d][f])}for(let d of t?.compoundVariants??[])if(Lt(d,a,r)){let f=d.class;typeof f=="string"&&u.push(f)}let h=s?.class??s?.className;return typeof h=="string"&&u.push(h),ie(re(u))}}function Lt(e,t,n){for(let r of Object.keys(e)){if(r==="class")continue;let s=e[r],a=t[r]??n[r]??void 0;if(Array.isArray(s)){if(!s.includes(a))return!1}else if(s!==a)return!1}return!0}function yt(e){let t=Pe(e?.children);return t?(Re(t,e),t):null}function Pe(e){if(e==null)return null;if(Array.isArray(e)){for(let t of e){let n=Pe(t);if(n)return n}return null}return e instanceof Node?e:null}function Re(e,t){if(e instanceof Element)for(let n of Object.keys(t)){if(n==="children"||n==="ref")continue;let r=t[n];if(!(r==null||r===!1)){if(n==="class"||n==="className"){let s=e.getAttribute("class"),a=s?s+" "+String(r):String(r);e.setAttribute("class",a);continue}if(n==="style"&&typeof r=="object"){for(let[s,a]of Object.entries(r))e.style.setProperty(xt(s),String(a));continue}if(n.startsWith("on")&&typeof r=="function"){e[n]=r;continue}if(r===!0){e.setAttribute(n,"");continue}e.setAttribute(n,String(r))}}}function xt(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function St(e,t,...n){if(!(e instanceof Node))return e;if(t&&Re(e,t),n.length>0&&e instanceof Element){e.textContent="";for(let r of n)r instanceof Node?e.appendChild(r):r!=null&&e.appendChild(document.createTextNode(String(r)))}return e}return Xe(kt);})();
|
|
2
2
|
for (const k in __krate_exports) { window[k] = __krate_exports[k]; }
|
package/dist/server-renderer.js
CHANGED
|
@@ -96,7 +96,23 @@ class ISRCache {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
|
|
99
|
+
// ISR cache size and the render timeout are configurable via the compiler
|
|
100
|
+
// (ssr.maxCacheSize / ssr.timeout), which exports them to the sidecar env.
|
|
101
|
+
const isrCache = new ISRCache(parseInt(process.env.KRATE_SSR_MAX_CACHE || "", 10) || 512);
|
|
102
|
+
// renderTimeoutMs bounds a single renderToString call so one pathological page
|
|
103
|
+
// cannot pin the sidecar. 0 disables the bound.
|
|
104
|
+
const renderTimeoutMs = parseInt(process.env.KRATE_SSR_TIMEOUT || "", 10) || 5000;
|
|
105
|
+
// withRenderTimeout rejects if p does not settle within renderTimeoutMs. The
|
|
106
|
+
// underlying render keeps running (JS cannot cancel it), but the request fails
|
|
107
|
+
// fast rather than hanging.
|
|
108
|
+
function withRenderTimeout(p) {
|
|
109
|
+
if (renderTimeoutMs <= 0)
|
|
110
|
+
return p;
|
|
111
|
+
return new Promise((resolve, reject) => {
|
|
112
|
+
const timer = setTimeout(() => reject(new Error(`render timed out after ${renderTimeoutMs}ms`)), renderTimeoutMs);
|
|
113
|
+
p.then((v) => { clearTimeout(timer); resolve(v); }, (e) => { clearTimeout(timer); reject(e); });
|
|
114
|
+
});
|
|
115
|
+
}
|
|
100
116
|
// ISR cache persistence — survives renderer restarts so a bounce doesn't
|
|
101
117
|
// cold-render every ISR variant. Written debounced (coalesced) to the build
|
|
102
118
|
// output dir (.krate/isr-cache.json), overridable via KRATE_ISR_CACHE.
|
|
@@ -203,7 +219,10 @@ async function renderFresh(page, req) {
|
|
|
203
219
|
return { html: "", status: 500 };
|
|
204
220
|
}
|
|
205
221
|
const jsxNode = Component(buildProps(req));
|
|
206
|
-
|
|
222
|
+
// Bound the render. renderToString is synchronous, so a page that blocks
|
|
223
|
+
// would block the sidecar's event loop regardless; the timeout still
|
|
224
|
+
// protects the request path when rendering is async (suspense/resource).
|
|
225
|
+
const html = await withRenderTimeout(Promise.resolve(renderToString(jsxNode)));
|
|
207
226
|
const response = {
|
|
208
227
|
html,
|
|
209
228
|
status: 200,
|
|
@@ -548,6 +567,12 @@ const server = http.createServer(async (req, res) => {
|
|
|
548
567
|
moduleCache.delete(key);
|
|
549
568
|
console.log(`[krate-ssr] Invalidated cache for ${targetRoute} (${key})`);
|
|
550
569
|
}
|
|
570
|
+
// Runtime component bundles are recompiled in place on a dev rebuild, but
|
|
571
|
+
// their render functions are cached for the process lifetime. Clear them
|
|
572
|
+
// so the next region render picks up the new code. Bundles are tiny and
|
|
573
|
+
// re-read on demand, so clearing all of them is cheap and avoids tracking
|
|
574
|
+
// which component maps to which route here.
|
|
575
|
+
runtimeBundleCache.clear();
|
|
551
576
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
552
577
|
res.end(JSON.stringify({ ok: true }));
|
|
553
578
|
}
|
package/dist/signal.d.ts
CHANGED
|
@@ -102,6 +102,14 @@ export declare function createEffect(fn: () => void): () => void;
|
|
|
102
102
|
export declare function onCleanup(fn: () => void): void;
|
|
103
103
|
export declare function onMount(fn: () => void): void;
|
|
104
104
|
export declare function createMemo<T>(fn: () => T): () => T;
|
|
105
|
+
/**
|
|
106
|
+
* Reducer state primitive: a `createSignal` whose setter applies a reducer.
|
|
107
|
+
* Returns `[getter, dispatch]` — the getter contract matches `createSignal`, so
|
|
108
|
+
* compiler slot bindings read it as `getter()` and hydration treats it like any
|
|
109
|
+
* other signal. Used both directly and as the lowering target for React's
|
|
110
|
+
* `useReducer`.
|
|
111
|
+
*/
|
|
112
|
+
export declare function createReducer<S, A>(reducer: (state: S, action: A) => S, initial: S): [() => S, (action: A) => void];
|
|
105
113
|
/** A mutable ref object. `current` starts as `initial` and is assigned the
|
|
106
114
|
* DOM element when passed as `ref={refObj}` on an element. */
|
|
107
115
|
export interface RefObject<T> {
|
package/dist/signal.js
CHANGED
|
@@ -265,6 +265,18 @@ export function createMemo(fn) {
|
|
|
265
265
|
}
|
|
266
266
|
return get;
|
|
267
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Reducer state primitive: a `createSignal` whose setter applies a reducer.
|
|
270
|
+
* Returns `[getter, dispatch]` — the getter contract matches `createSignal`, so
|
|
271
|
+
* compiler slot bindings read it as `getter()` and hydration treats it like any
|
|
272
|
+
* other signal. Used both directly and as the lowering target for React's
|
|
273
|
+
* `useReducer`.
|
|
274
|
+
*/
|
|
275
|
+
export function createReducer(reducer, initial) {
|
|
276
|
+
const [get, set] = createSignal(initial);
|
|
277
|
+
const dispatch = (action) => set((prev) => reducer(prev, action));
|
|
278
|
+
return [get, dispatch];
|
|
279
|
+
}
|
|
268
280
|
/**
|
|
269
281
|
* Create a mutable ref object. Unlike React, `useRef` always allocates a
|
|
270
282
|
* fresh `{current: initial}` object; Krate components run their body once per
|
package/package.json
CHANGED