sibujs 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1630 -0
- package/dist/browser.cjs +815 -0
- package/dist/browser.d.cts +174 -0
- package/dist/browser.d.ts +174 -0
- package/dist/browser.js +458 -0
- package/dist/build.cjs +4970 -0
- package/dist/build.d.cts +630 -0
- package/dist/build.d.ts +630 -0
- package/dist/build.js +2478 -0
- package/dist/cdn.global.js +115 -0
- package/dist/chunk-27QC4FPL.js +67 -0
- package/dist/chunk-2ABBWCGC.js +65 -0
- package/dist/chunk-2MUNQYZ7.js +26 -0
- package/dist/chunk-2PSPKNUI.js +1711 -0
- package/dist/chunk-35CDLDX5.js +1758 -0
- package/dist/chunk-36MU4CFV.js +41 -0
- package/dist/chunk-3FIQOFI6.js +182 -0
- package/dist/chunk-3GHNC2BN.js +28 -0
- package/dist/chunk-3HLWWEPU.js +909 -0
- package/dist/chunk-3IVI3J54.js +252 -0
- package/dist/chunk-3KZ72WNW.js +944 -0
- package/dist/chunk-4AU64SQV.js +182 -0
- package/dist/chunk-4MOK7HAR.js +84 -0
- package/dist/chunk-4QK6FBDH.js +1429 -0
- package/dist/chunk-566Z7HXB.js +737 -0
- package/dist/chunk-5CRBB7XP.js +358 -0
- package/dist/chunk-5G67D3IZ.js +168 -0
- package/dist/chunk-5NCPAWBE.js +99 -0
- package/dist/chunk-5O2RKXR3.js +1444 -0
- package/dist/chunk-6BTBDO6A.js +633 -0
- package/dist/chunk-6IWEHW57.js +43 -0
- package/dist/chunk-6JGMNCD6.js +282 -0
- package/dist/chunk-6QRLJNXR.js +1425 -0
- package/dist/chunk-7HM5UE5T.js +270 -0
- package/dist/chunk-7JOLTGUH.js +58 -0
- package/dist/chunk-7MCWJCQK.js +909 -0
- package/dist/chunk-7RIIFP3E.js +1758 -0
- package/dist/chunk-7UASYN3G.js +254 -0
- package/dist/chunk-7W2WYHDI.js +741 -0
- package/dist/chunk-7Y35RDSJ.js +872 -0
- package/dist/chunk-A65GFJBL.js +65 -0
- package/dist/chunk-AD6ZIEDK.js +67 -0
- package/dist/chunk-AK5Y72F3.js +1426 -0
- package/dist/chunk-APOMMWH4.js +282 -0
- package/dist/chunk-ARZVTWIQ.js +1750 -0
- package/dist/chunk-AWWBM2BI.js +664 -0
- package/dist/chunk-AX5VEQTY.js +58 -0
- package/dist/chunk-AYTXVOW3.js +1708 -0
- package/dist/chunk-BG4A246G.js +1746 -0
- package/dist/chunk-BNFJJA2L.js +1425 -0
- package/dist/chunk-BPKPBVU5.js +59 -0
- package/dist/chunk-BPKPPSXC.js +282 -0
- package/dist/chunk-BPWKKK7F.js +1711 -0
- package/dist/chunk-CCKX6YTC.js +1735 -0
- package/dist/chunk-CIF5Z3MP.js +58 -0
- package/dist/chunk-CSXYU7IO.js +457 -0
- package/dist/chunk-D6JD4FDC.js +26 -0
- package/dist/chunk-E7NGA7X2.js +59 -0
- package/dist/chunk-EEPPJKAE.js +443 -0
- package/dist/chunk-EJMYGAGQ.js +717 -0
- package/dist/chunk-EL6Z5MDY.js +55 -0
- package/dist/chunk-EP7VRLEB.js +41 -0
- package/dist/chunk-ETMEC6FH.js +99 -0
- package/dist/chunk-EZ2WHYVL.js +65 -0
- package/dist/chunk-EZRVMSZK.js +67 -0
- package/dist/chunk-F2TRGINX.js +254 -0
- package/dist/chunk-F5JCIH3Q.js +642 -0
- package/dist/chunk-FGK3JKMN.js +909 -0
- package/dist/chunk-FQWPKSTD.js +1437 -0
- package/dist/chunk-FWHVLMCI.js +26 -0
- package/dist/chunk-GBEYQRO2.js +303 -0
- package/dist/chunk-GBLES3NK.js +248 -0
- package/dist/chunk-GQVGUQW6.js +1436 -0
- package/dist/chunk-HCV2T76T.js +457 -0
- package/dist/chunk-HS7ZKVPR.js +182 -0
- package/dist/chunk-HXDVV7HZ.js +909 -0
- package/dist/chunk-IB23VMO3.js +1746 -0
- package/dist/chunk-IEMZ7RTT.js +99 -0
- package/dist/chunk-IPGRSN42.js +1750 -0
- package/dist/chunk-IVMOK2QN.js +1750 -0
- package/dist/chunk-JCLGQO7T.js +443 -0
- package/dist/chunk-JDXL7KDB.js +1436 -0
- package/dist/chunk-JIIFW636.js +270 -0
- package/dist/chunk-JWGEEH7H.js +944 -0
- package/dist/chunk-K2BESAG7.js +1688 -0
- package/dist/chunk-K2U5YGF4.js +877 -0
- package/dist/chunk-K45FQ4Y4.js +175 -0
- package/dist/chunk-K7BPE427.js +1432 -0
- package/dist/chunk-KL3266RS.js +26 -0
- package/dist/chunk-KNN4P7DZ.js +84 -0
- package/dist/chunk-KP2DZH5Q.js +254 -0
- package/dist/chunk-KZHAJSQR.js +1636 -0
- package/dist/chunk-LBKGHMQV.js +1750 -0
- package/dist/chunk-LBTEPL7A.js +1731 -0
- package/dist/chunk-LEBBPTDB.js +1444 -0
- package/dist/chunk-LLH63WVQ.js +98 -0
- package/dist/chunk-LWVR2C4G.js +1711 -0
- package/dist/chunk-M3MDTVV2.js +896 -0
- package/dist/chunk-M5GNLDEO.js +303 -0
- package/dist/chunk-MFHVGKET.js +267 -0
- package/dist/chunk-MGWSG3PM.js +358 -0
- package/dist/chunk-MJNB47HB.js +19 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-MQWTY3JY.js +944 -0
- package/dist/chunk-MZZOQHNI.js +642 -0
- package/dist/chunk-NIHWGZS4.js +1426 -0
- package/dist/chunk-NSVVHQK5.js +41 -0
- package/dist/chunk-NVI2WE7D.js +443 -0
- package/dist/chunk-O7QBO3PH.js +58 -0
- package/dist/chunk-OAUPQBO2.js +270 -0
- package/dist/chunk-OB2LMD7C.js +297 -0
- package/dist/chunk-OHEYBWQU.js +58 -0
- package/dist/chunk-OI6OXUHJ.js +443 -0
- package/dist/chunk-OX2VMRMV.js +633 -0
- package/dist/chunk-P4FYE5TX.js +866 -0
- package/dist/chunk-P5KFWM4H.js +98 -0
- package/dist/chunk-PUMLE7RJ.js +1711 -0
- package/dist/chunk-Q4MFANBF.js +282 -0
- package/dist/chunk-QLEKZMMU.js +282 -0
- package/dist/chunk-RGGNGVO3.js +98 -0
- package/dist/chunk-RKJDRVV6.js +443 -0
- package/dist/chunk-S5BHU353.js +43 -0
- package/dist/chunk-SHQUSFH7.js +1426 -0
- package/dist/chunk-SMB4DBMD.js +182 -0
- package/dist/chunk-SNYHQP3D.js +743 -0
- package/dist/chunk-T24L3TBF.js +1717 -0
- package/dist/chunk-TAQNSOKT.js +692 -0
- package/dist/chunk-TDNY4SUA.js +41 -0
- package/dist/chunk-TNNF56IQ.js +1750 -0
- package/dist/chunk-TR7E6LYX.js +457 -0
- package/dist/chunk-URWUFH45.js +98 -0
- package/dist/chunk-UUSIH3XH.js +1429 -0
- package/dist/chunk-UYFNXLKR.js +1436 -0
- package/dist/chunk-V6F7KUWD.js +270 -0
- package/dist/chunk-VCZLXRMR.js +254 -0
- package/dist/chunk-VDHXSSBT.js +1426 -0
- package/dist/chunk-VM4QMKVK.js +254 -0
- package/dist/chunk-VWGYKYL2.js +737 -0
- package/dist/chunk-VX2OFBJN.js +1426 -0
- package/dist/chunk-VXVIE6DG.js +84 -0
- package/dist/chunk-W4OH7HG4.js +40 -0
- package/dist/chunk-WBVJX4GZ.js +98 -0
- package/dist/chunk-WDU2ZV4I.js +1426 -0
- package/dist/chunk-X6VUCICU.js +457 -0
- package/dist/chunk-XAY7FM7Y.js +618 -0
- package/dist/chunk-XJZ5Z2CM.js +642 -0
- package/dist/chunk-XKVFQTJJ.js +254 -0
- package/dist/chunk-XRLFASCY.js +22 -0
- package/dist/chunk-XYU6TZOW.js +182 -0
- package/dist/chunk-Y745CBVB.js +944 -0
- package/dist/chunk-YLBJSXYY.js +944 -0
- package/dist/chunk-YQJIKVPZ.js +1429 -0
- package/dist/chunk-YRM2VCZF.js +457 -0
- package/dist/chunk-YS33KBVJ.js +944 -0
- package/dist/chunk-Z27DZPDG.js +41 -0
- package/dist/chunk-ZXQ5NAEN.js +32 -0
- package/dist/contracts-B552GopR.d.cts +245 -0
- package/dist/contracts-B552GopR.d.ts +245 -0
- package/dist/contracts-Bg1ECISC.d.cts +245 -0
- package/dist/contracts-Bg1ECISC.d.ts +245 -0
- package/dist/contracts-CMriKJ6P.d.cts +245 -0
- package/dist/contracts-CMriKJ6P.d.ts +245 -0
- package/dist/contracts-DOrhwbke.d.cts +245 -0
- package/dist/contracts-DOrhwbke.d.ts +245 -0
- package/dist/data.cjs +1373 -0
- package/dist/data.d.cts +434 -0
- package/dist/data.d.ts +434 -0
- package/dist/data.js +945 -0
- package/dist/devtools.cjs +1357 -0
- package/dist/devtools.d.cts +473 -0
- package/dist/devtools.d.ts +473 -0
- package/dist/devtools.js +1084 -0
- package/dist/ecosystem.cjs +1046 -0
- package/dist/ecosystem.d.cts +247 -0
- package/dist/ecosystem.d.ts +247 -0
- package/dist/ecosystem.js +369 -0
- package/dist/extras.cjs +8457 -0
- package/dist/extras.d.cts +2356 -0
- package/dist/extras.d.ts +2356 -0
- package/dist/extras.js +5152 -0
- package/dist/index.cjs +2648 -0
- package/dist/index.d.cts +869 -0
- package/dist/index.d.ts +869 -0
- package/dist/index.js +386 -0
- package/dist/motion.cjs +604 -0
- package/dist/motion.d.cts +146 -0
- package/dist/motion.d.ts +146 -0
- package/dist/motion.js +346 -0
- package/dist/patterns.cjs +815 -0
- package/dist/patterns.d.cts +163 -0
- package/dist/patterns.d.ts +163 -0
- package/dist/patterns.js +296 -0
- package/dist/performance.cjs +927 -0
- package/dist/performance.d.cts +416 -0
- package/dist/performance.d.ts +416 -0
- package/dist/performance.js +654 -0
- package/dist/plugins.cjs +2487 -0
- package/dist/plugins.d.cts +393 -0
- package/dist/plugins.d.ts +393 -0
- package/dist/plugins.js +1504 -0
- package/dist/signal-BnWpq6WB.d.cts +5 -0
- package/dist/signal-BnWpq6WB.d.ts +5 -0
- package/dist/src/components/ErrorBoundary.d.ts +15 -0
- package/dist/src/components/ErrorBoundary.js +119 -0
- package/dist/src/core/catch.d.ts +11 -0
- package/dist/src/core/catch.js +28 -0
- package/dist/src/core/each.d.ts +13 -0
- package/dist/src/core/each.js +68 -0
- package/dist/src/core/for.d.ts +12 -0
- package/dist/src/core/for.js +67 -0
- package/dist/src/core/html.d.ts +137 -0
- package/dist/src/core/html.js +155 -0
- package/dist/src/core/htmlIf.d.ts +11 -0
- package/dist/src/core/htmlIf.js +18 -0
- package/dist/src/core/lazy.d.ts +7 -0
- package/dist/src/core/lazy.js +16 -0
- package/dist/src/core/mount.d.ts +7 -0
- package/dist/src/core/mount.js +12 -0
- package/dist/src/core/slots.d.ts +3 -0
- package/dist/src/core/slots.js +3 -0
- package/dist/src/core/suspense.d.ts +10 -0
- package/dist/src/core/suspense.js +33 -0
- package/dist/src/core/tagFactory.d.ts +13 -0
- package/dist/src/core/tagFactory.js +86 -0
- package/dist/src/core/test.d.ts +11 -0
- package/dist/src/core/test.js +28 -0
- package/dist/src/core/types.d.ts +2 -0
- package/dist/src/core/types.js +1 -0
- package/dist/src/core/useComputed.d.ts +6 -0
- package/dist/src/core/useComputed.js +30 -0
- package/dist/src/core/useEffect.d.ts +6 -0
- package/dist/src/core/useEffect.js +23 -0
- package/dist/src/core/useState.d.ts +10 -0
- package/dist/src/core/useState.js +34 -0
- package/dist/src/core/useStore.d.ts +19 -0
- package/dist/src/core/useStore.js +53 -0
- package/dist/src/core/useWatch.d.ts +8 -0
- package/dist/src/core/useWatch.js +23 -0
- package/dist/src/plugins/i18n.d.ts +6 -0
- package/dist/src/plugins/i18n.js +16 -0
- package/dist/src/plugins/router.d.ts +188 -0
- package/dist/src/plugins/router.js +1178 -0
- package/dist/src/reactivity/bindAttribute.d.ts +5 -0
- package/dist/src/reactivity/bindAttribute.js +31 -0
- package/dist/src/reactivity/bindChildNode.d.ts +10 -0
- package/dist/src/reactivity/bindChildNode.js +46 -0
- package/dist/src/reactivity/bindTextNode.d.ts +10 -0
- package/dist/src/reactivity/bindTextNode.js +27 -0
- package/dist/src/reactivity/signal.d.ts +3 -0
- package/dist/src/reactivity/signal.js +1 -0
- package/dist/src/reactivity/track.d.ts +18 -0
- package/dist/src/reactivity/track.js +73 -0
- package/dist/src/reactivity/useComputed.d.ts +6 -0
- package/dist/src/reactivity/useComputed.js +30 -0
- package/dist/src/reactivity/useEffect.d.ts +6 -0
- package/dist/src/reactivity/useEffect.js +23 -0
- package/dist/src/reactivity/useState.d.ts +10 -0
- package/dist/src/reactivity/useState.js +34 -0
- package/dist/src/reactivity/useStore.d.ts +19 -0
- package/dist/src/reactivity/useStore.js +53 -0
- package/dist/src/reactivity/useWatch.d.ts +8 -0
- package/dist/src/reactivity/useWatch.js +23 -0
- package/dist/src/utils/sanitize.d.ts +1 -0
- package/dist/src/utils/sanitize.js +8 -0
- package/dist/ssr-27FOM46T.js +35 -0
- package/dist/ssr-GFUTTSJD.js +22 -0
- package/dist/ssr-K7DCR6BZ.js +35 -0
- package/dist/ssr-O6LFMRFP.js +35 -0
- package/dist/ssr-QZEVGMMK.js +35 -0
- package/dist/ssr-SGVBCAGC.js +35 -0
- package/dist/ssr-UB2IXCYX.js +35 -0
- package/dist/ssr-XBZQNV4O.js +22 -0
- package/dist/ssr-Y76FSXDU.js +35 -0
- package/dist/ssr-YQJ4AYBD.js +35 -0
- package/dist/ssr.cjs +1757 -0
- package/dist/ssr.d.cts +478 -0
- package/dist/ssr.d.ts +478 -0
- package/dist/ssr.js +743 -0
- package/dist/tagFactory-CZPO4RXF.d.cts +34 -0
- package/dist/tagFactory-CZPO4RXF.d.ts +34 -0
- package/dist/tagFactory-CgImPVMY.d.cts +22 -0
- package/dist/tagFactory-CgImPVMY.d.ts +22 -0
- package/dist/tagFactory-Cw1iv5if.d.cts +22 -0
- package/dist/tagFactory-Cw1iv5if.d.ts +22 -0
- package/dist/tagFactory-DeAXq9ef.d.cts +30 -0
- package/dist/tagFactory-DeAXq9ef.d.ts +30 -0
- package/dist/tagFactory-SkY0a7L1.d.cts +22 -0
- package/dist/tagFactory-SkY0a7L1.d.ts +22 -0
- package/dist/testing.cjs +1919 -0
- package/dist/testing.d.cts +491 -0
- package/dist/testing.d.ts +491 -0
- package/dist/testing.js +1862 -0
- package/dist/ui.cjs +1497 -0
- package/dist/ui.d.cts +264 -0
- package/dist/ui.d.ts +264 -0
- package/dist/ui.js +900 -0
- package/dist/widgets.cjs +919 -0
- package/dist/widgets.d.cts +165 -0
- package/dist/widgets.d.ts +165 -0
- package/dist/widgets.js +545 -0
- package/package.json +134 -0
package/dist/data.d.ts
ADDED
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configurable retry strategies for async operations.
|
|
3
|
+
* Used by `resource` and `query` for automatic error recovery.
|
|
4
|
+
*/
|
|
5
|
+
interface RetryOptions {
|
|
6
|
+
/** Maximum number of retry attempts. Default: 3 */
|
|
7
|
+
maxRetries?: number;
|
|
8
|
+
/** Retry strategy. Default: "exponential" */
|
|
9
|
+
strategy?: "exponential" | "linear" | "fixed";
|
|
10
|
+
/** Base delay in ms. Default: 1000 */
|
|
11
|
+
baseDelay?: number;
|
|
12
|
+
/** Maximum delay in ms (caps exponential growth). Default: 30000 */
|
|
13
|
+
maxDelay?: number;
|
|
14
|
+
/** Jitter factor (0-1) to randomize delay. Default: 0.1 */
|
|
15
|
+
jitter?: number;
|
|
16
|
+
/** Predicate to decide if an error is retryable. Default: () => true */
|
|
17
|
+
shouldRetry?: (error: unknown, attempt: number) => boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Calculate delay for a given attempt based on strategy.
|
|
21
|
+
*/
|
|
22
|
+
declare function calculateDelay(attempt: number, strategy: "exponential" | "linear" | "fixed", baseDelay: number, maxDelay: number, jitter: number): number;
|
|
23
|
+
/**
|
|
24
|
+
* Execute an async function with retry logic.
|
|
25
|
+
* Returns the result or throws after all retries are exhausted.
|
|
26
|
+
*
|
|
27
|
+
* @param fn The async function to execute
|
|
28
|
+
* @param options Retry configuration
|
|
29
|
+
* @param onRetry Callback fired before each retry with error, attempt, and delay
|
|
30
|
+
* @param signal AbortSignal to cancel retries
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const data = await withRetry(() => fetch("/api/data").then(r => r.json()), {
|
|
35
|
+
* maxRetries: 3,
|
|
36
|
+
* strategy: "exponential",
|
|
37
|
+
* shouldRetry: (err) => !(err instanceof TypeError),
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions, onRetry?: (error: unknown, attempt: number, delay: number) => void, signal?: AbortSignal): Promise<T>;
|
|
42
|
+
|
|
43
|
+
interface QueryOptions<T> {
|
|
44
|
+
/** Time in ms before cached data is considered stale. Default: 0 (always stale) */
|
|
45
|
+
staleTime?: number;
|
|
46
|
+
/** Time in ms to keep unused cache entries. Default: 300000 (5 min) */
|
|
47
|
+
cacheTime?: number;
|
|
48
|
+
/** Whether to fetch on creation. Default: true */
|
|
49
|
+
enabled?: boolean;
|
|
50
|
+
/** Retry options for failed fetches */
|
|
51
|
+
retry?: RetryOptions;
|
|
52
|
+
/** Initial data before first fetch */
|
|
53
|
+
initialData?: T;
|
|
54
|
+
/** Auto-refetch interval in ms */
|
|
55
|
+
refetchInterval?: number;
|
|
56
|
+
/** Refetch when window regains focus */
|
|
57
|
+
refetchOnWindowFocus?: boolean;
|
|
58
|
+
/** Refetch when network reconnects */
|
|
59
|
+
refetchOnReconnect?: boolean;
|
|
60
|
+
/** Called on successful fetch */
|
|
61
|
+
onSuccess?: (data: T) => void;
|
|
62
|
+
/** Called on fetch error */
|
|
63
|
+
onError?: (error: Error) => void;
|
|
64
|
+
/** Called on fetch settle (success or error) */
|
|
65
|
+
onSettled?: () => void;
|
|
66
|
+
}
|
|
67
|
+
interface QueryResult<T> {
|
|
68
|
+
/** Reactive getter for the cached data */
|
|
69
|
+
data: () => T | undefined;
|
|
70
|
+
/** Reactive getter: true when fetching with no cached data */
|
|
71
|
+
loading: () => boolean;
|
|
72
|
+
/** Reactive getter: true when any fetch is in progress */
|
|
73
|
+
fetching: () => boolean;
|
|
74
|
+
/** Reactive getter for the error state */
|
|
75
|
+
error: () => Error | undefined;
|
|
76
|
+
/** Reactive getter: whether cached data is stale */
|
|
77
|
+
isStale: () => boolean;
|
|
78
|
+
/** Manually trigger a refetch */
|
|
79
|
+
refetch: () => Promise<void>;
|
|
80
|
+
/** Cleanup subscriptions and timers */
|
|
81
|
+
dispose: () => void;
|
|
82
|
+
}
|
|
83
|
+
declare function query<T>(key: string | (() => string), fetcher: (ctx: {
|
|
84
|
+
signal: AbortSignal;
|
|
85
|
+
key: string;
|
|
86
|
+
}) => Promise<T>, options?: QueryOptions<T>): QueryResult<T>;
|
|
87
|
+
/** Invalidate queries matching a key or predicate, triggering refetch for active subscribers */
|
|
88
|
+
declare function invalidateQueries(keyOrPredicate: string | ((key: string) => boolean)): void;
|
|
89
|
+
/** Get cached data for a query key */
|
|
90
|
+
declare function getQueryData<T>(key: string): T | undefined;
|
|
91
|
+
/** Set cached data for a query key, notifying subscribers */
|
|
92
|
+
declare function setQueryData<T>(key: string, data: T | ((prev: T | undefined) => T)): void;
|
|
93
|
+
/** Clear the entire query cache */
|
|
94
|
+
declare function clearQueryCache(): void;
|
|
95
|
+
|
|
96
|
+
interface MutationOptions<TData, TVariables, TContext = unknown> {
|
|
97
|
+
/** Retry options for failed mutations */
|
|
98
|
+
retry?: RetryOptions;
|
|
99
|
+
/** Called before mutation — return context for rollback in onError */
|
|
100
|
+
onMutate?: (variables: TVariables) => TContext | Promise<TContext>;
|
|
101
|
+
/** Called on successful mutation */
|
|
102
|
+
onSuccess?: (data: TData, variables: TVariables, context: TContext) => void;
|
|
103
|
+
/** Called on mutation error — context from onMutate available for rollback */
|
|
104
|
+
onError?: (error: Error, variables: TVariables, context: TContext | undefined) => void;
|
|
105
|
+
/** Called on mutation settle (success or error) */
|
|
106
|
+
onSettled?: (data: TData | undefined, error: Error | undefined, variables: TVariables, context: TContext | undefined) => void;
|
|
107
|
+
}
|
|
108
|
+
interface MutationResult<TData, TVariables> {
|
|
109
|
+
/** Reactive getter for the mutation result data */
|
|
110
|
+
data: () => TData | undefined;
|
|
111
|
+
/** Reactive getter for the loading state */
|
|
112
|
+
loading: () => boolean;
|
|
113
|
+
/** Reactive getter for the error state */
|
|
114
|
+
error: () => Error | undefined;
|
|
115
|
+
/** Reactive getter: true if mutation succeeded */
|
|
116
|
+
isSuccess: () => boolean;
|
|
117
|
+
/** Reactive getter: true if mutation has not been called */
|
|
118
|
+
isIdle: () => boolean;
|
|
119
|
+
/** Fire-and-forget mutation trigger */
|
|
120
|
+
mutate: (variables: TVariables) => void;
|
|
121
|
+
/** Mutation trigger that returns a promise */
|
|
122
|
+
mutateAsync: (variables: TVariables) => Promise<TData>;
|
|
123
|
+
/** Reset state to idle */
|
|
124
|
+
reset: () => void;
|
|
125
|
+
}
|
|
126
|
+
declare function mutation<TData, TVariables = void, TContext = unknown>(mutationFn: (variables: TVariables) => Promise<TData>, options?: MutationOptions<TData, TVariables, TContext>): MutationResult<TData, TVariables>;
|
|
127
|
+
|
|
128
|
+
interface InfiniteQueryOptions<TData, TPageParam = number> {
|
|
129
|
+
/** Get the param for the next page. Return undefined to signal end. */
|
|
130
|
+
getNextPageParam: (lastPage: TData, allPages: TData[]) => TPageParam | undefined;
|
|
131
|
+
/** Get the param for the previous page. Optional. */
|
|
132
|
+
getPreviousPageParam?: (firstPage: TData, allPages: TData[]) => TPageParam | undefined;
|
|
133
|
+
/** Initial page param. Default: 0 (for number) */
|
|
134
|
+
initialPageParam?: TPageParam;
|
|
135
|
+
/** Whether to fetch on creation. Default: true */
|
|
136
|
+
enabled?: boolean;
|
|
137
|
+
/** Retry options */
|
|
138
|
+
retry?: RetryOptions;
|
|
139
|
+
/** Called on successful page fetch */
|
|
140
|
+
onSuccess?: (data: TData[]) => void;
|
|
141
|
+
/** Called on fetch error */
|
|
142
|
+
onError?: (error: Error) => void;
|
|
143
|
+
}
|
|
144
|
+
interface InfiniteQueryResult<TData> {
|
|
145
|
+
/** All fetched pages combined */
|
|
146
|
+
data: () => TData[] | undefined;
|
|
147
|
+
/** Individual pages array */
|
|
148
|
+
pages: () => TData[];
|
|
149
|
+
/** True when loading the first page */
|
|
150
|
+
loading: () => boolean;
|
|
151
|
+
/** True when any fetch is in progress */
|
|
152
|
+
fetching: () => boolean;
|
|
153
|
+
/** True when fetching the next page */
|
|
154
|
+
fetchingNextPage: () => boolean;
|
|
155
|
+
/** True when fetching the previous page */
|
|
156
|
+
fetchingPreviousPage: () => boolean;
|
|
157
|
+
/** Error from the last fetch */
|
|
158
|
+
error: () => Error | undefined;
|
|
159
|
+
/** Whether there are more pages to fetch */
|
|
160
|
+
hasNextPage: () => boolean;
|
|
161
|
+
/** Whether there are previous pages */
|
|
162
|
+
hasPreviousPage: () => boolean;
|
|
163
|
+
/** Fetch the next page */
|
|
164
|
+
fetchNextPage: () => Promise<void>;
|
|
165
|
+
/** Fetch the previous page */
|
|
166
|
+
fetchPreviousPage: () => Promise<void>;
|
|
167
|
+
/** Refetch all pages */
|
|
168
|
+
refetch: () => Promise<void>;
|
|
169
|
+
/** Cleanup */
|
|
170
|
+
dispose: () => void;
|
|
171
|
+
}
|
|
172
|
+
declare function infiniteQuery<TData, TPageParam = number>(key: string | (() => string), fetcher: (ctx: {
|
|
173
|
+
signal: AbortSignal;
|
|
174
|
+
pageParam: TPageParam;
|
|
175
|
+
}) => Promise<TData>, options: InfiniteQueryOptions<TData, TPageParam>): InfiniteQueryResult<TData>;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Tracks the previous value of a reactive signal.
|
|
179
|
+
* Returns `undefined` on first read (there is no previous value yet).
|
|
180
|
+
*
|
|
181
|
+
* @param getter A reactive getter to track
|
|
182
|
+
* @returns A reactive getter for the previous value
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* const [count, setCount] = signal(0);
|
|
187
|
+
* const prev = previous(count);
|
|
188
|
+
* prev(); // undefined
|
|
189
|
+
* setCount(5);
|
|
190
|
+
* prev(); // 0
|
|
191
|
+
* setCount(10);
|
|
192
|
+
* prev(); // 5
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
declare function previous<T>(getter: () => T): () => T | undefined;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Returns a debounced reactive getter that only updates after `delay` ms
|
|
199
|
+
* of inactivity from the source signal.
|
|
200
|
+
*
|
|
201
|
+
* @param getter A reactive getter to debounce
|
|
202
|
+
* @param delay Debounce delay in milliseconds
|
|
203
|
+
* @returns A reactive getter for the debounced value
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```ts
|
|
207
|
+
* const [search, setSearch] = signal("");
|
|
208
|
+
* const debouncedSearch = debounce(search, 300);
|
|
209
|
+
* // debouncedSearch() only updates 300ms after the last setSearch call
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
declare function debounce<T>(getter: () => T, delay: number): () => T;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Returns a throttled reactive getter that updates at most once per `interval` ms.
|
|
216
|
+
* Leading edge: first change propagates immediately.
|
|
217
|
+
* Trailing edge: last change during cooldown propagates when cooldown ends.
|
|
218
|
+
*
|
|
219
|
+
* @param getter A reactive getter to throttle
|
|
220
|
+
* @param interval Throttle interval in milliseconds
|
|
221
|
+
* @returns A reactive getter for the throttled value
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```ts
|
|
225
|
+
* const [scrollY, setScrollY] = signal(0);
|
|
226
|
+
* const throttled = throttle(scrollY, 100);
|
|
227
|
+
* // throttled() updates at most once every 100ms
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
declare function throttle<T>(getter: () => T, interval: number): () => T;
|
|
231
|
+
|
|
232
|
+
interface ResourceOptions<T> {
|
|
233
|
+
/** Initial data value before first fetch. Default: undefined */
|
|
234
|
+
initialValue?: T;
|
|
235
|
+
/** Retry options for failed fetches */
|
|
236
|
+
retry?: RetryOptions;
|
|
237
|
+
/** Whether to fetch immediately on creation. Default: true */
|
|
238
|
+
immediate?: boolean;
|
|
239
|
+
/** Called when a fetch starts */
|
|
240
|
+
onStart?: () => void;
|
|
241
|
+
/** Called on successful fetch */
|
|
242
|
+
onSuccess?: (data: T) => void;
|
|
243
|
+
/** Called on fetch error */
|
|
244
|
+
onError?: (error: Error) => void;
|
|
245
|
+
/** Called on fetch settle (success or error) */
|
|
246
|
+
onSettled?: () => void;
|
|
247
|
+
}
|
|
248
|
+
interface Resource<T> {
|
|
249
|
+
/** Reactive getter for the fetched data */
|
|
250
|
+
data: () => T | undefined;
|
|
251
|
+
/** Reactive getter for the loading state */
|
|
252
|
+
loading: () => boolean;
|
|
253
|
+
/** Reactive getter for the error state */
|
|
254
|
+
error: () => Error | undefined;
|
|
255
|
+
/** Manually trigger a refetch */
|
|
256
|
+
refetch: () => Promise<void>;
|
|
257
|
+
/** Mutate the cached data without refetching */
|
|
258
|
+
mutate: (value: T | ((prev: T | undefined) => T)) => void;
|
|
259
|
+
/** Abort the current in-flight request */
|
|
260
|
+
abort: () => void;
|
|
261
|
+
/** Cleanup all subscriptions and abort pending requests */
|
|
262
|
+
dispose: () => void;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Reactive async data primitive. Wraps a fetcher function and exposes
|
|
266
|
+
* `data()`, `loading()`, `error()` signals.
|
|
267
|
+
*
|
|
268
|
+
* Overload 1: fetcher with no source signal (manual or immediate fetch).
|
|
269
|
+
*/
|
|
270
|
+
declare function resource<T>(fetcher: (info: {
|
|
271
|
+
signal: AbortSignal;
|
|
272
|
+
}) => Promise<T>, options?: ResourceOptions<T>): Resource<T>;
|
|
273
|
+
/**
|
|
274
|
+
* Overload 2: fetcher with a reactive source signal.
|
|
275
|
+
* Auto-refetches when the source changes.
|
|
276
|
+
*/
|
|
277
|
+
declare function resource<T, S>(source: () => S, fetcher: (source: S, info: {
|
|
278
|
+
signal: AbortSignal;
|
|
279
|
+
prev: T | undefined;
|
|
280
|
+
}) => Promise<T>, options?: ResourceOptions<T>): Resource<T>;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Offline-first data store backed by IndexedDB with reactive state.
|
|
284
|
+
* Provides automatic sync when connectivity returns.
|
|
285
|
+
*/
|
|
286
|
+
interface OfflineStoreOptions<T> {
|
|
287
|
+
/** IndexedDB database name */
|
|
288
|
+
name: string;
|
|
289
|
+
/** Version for schema migrations */
|
|
290
|
+
version?: number;
|
|
291
|
+
/** Key path in the stored objects (default: "id") */
|
|
292
|
+
keyPath?: string;
|
|
293
|
+
/** Sync adapter for remote push/pull */
|
|
294
|
+
adapter?: SyncAdapter<T>;
|
|
295
|
+
/** Auto-sync when online status changes (default: true) */
|
|
296
|
+
autoSync?: boolean;
|
|
297
|
+
}
|
|
298
|
+
interface SyncAdapter<T> {
|
|
299
|
+
/** Push local changes to remote */
|
|
300
|
+
push: (changes: SyncChange<T>[]) => Promise<SyncResult>;
|
|
301
|
+
/** Pull remote changes since last sync */
|
|
302
|
+
pull: (since: number | null) => Promise<T[]>;
|
|
303
|
+
/** Conflict resolution strategy */
|
|
304
|
+
conflictStrategy: "client-wins" | "server-wins" | "manual";
|
|
305
|
+
}
|
|
306
|
+
interface SyncChange<T> {
|
|
307
|
+
type: "put" | "delete";
|
|
308
|
+
item: T;
|
|
309
|
+
timestamp: number;
|
|
310
|
+
}
|
|
311
|
+
interface SyncResult {
|
|
312
|
+
ok: boolean;
|
|
313
|
+
error?: string;
|
|
314
|
+
}
|
|
315
|
+
interface OfflineStore<T> {
|
|
316
|
+
/** Reactive getter for all items */
|
|
317
|
+
data: () => T[];
|
|
318
|
+
/** Get a single item by key */
|
|
319
|
+
get: (key: string | number) => Promise<T | undefined>;
|
|
320
|
+
/** Insert or update an item */
|
|
321
|
+
put: (item: T) => Promise<void>;
|
|
322
|
+
/** Delete an item by key */
|
|
323
|
+
remove: (key: string | number) => Promise<void>;
|
|
324
|
+
/** Query items with a filter */
|
|
325
|
+
query: (filter: (item: T) => boolean) => T[];
|
|
326
|
+
/** Whether a sync is in progress */
|
|
327
|
+
isSyncing: () => boolean;
|
|
328
|
+
/** Timestamp of last successful sync */
|
|
329
|
+
lastSynced: () => number | null;
|
|
330
|
+
/** Trigger a manual sync */
|
|
331
|
+
sync: () => Promise<void>;
|
|
332
|
+
/** Attach a sync adapter */
|
|
333
|
+
attach: (adapter: SyncAdapter<T>) => void;
|
|
334
|
+
/** Number of pending (un-synced) changes */
|
|
335
|
+
pendingCount: () => number;
|
|
336
|
+
/** Close the database connection */
|
|
337
|
+
close: () => void;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Create an offline-first reactive store backed by IndexedDB.
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```ts
|
|
344
|
+
* const store = await offlineStore<Todo>({
|
|
345
|
+
* name: "todos",
|
|
346
|
+
* adapter: syncAdapter({
|
|
347
|
+
* push: (changes) => fetch("/api/sync", { method: "POST", body: JSON.stringify(changes) }),
|
|
348
|
+
* pull: (since) => fetch(`/api/todos?since=${since}`).then(r => r.json()),
|
|
349
|
+
* conflictStrategy: "client-wins",
|
|
350
|
+
* }),
|
|
351
|
+
* });
|
|
352
|
+
*
|
|
353
|
+
* await store.put({ id: "1", text: "Buy milk", done: false });
|
|
354
|
+
* store.data(); // [{ id: "1", text: "Buy milk", done: false }]
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
declare function offlineStore<T extends Record<string, unknown>>(options: OfflineStoreOptions<T>): Promise<OfflineStore<T>>;
|
|
358
|
+
/**
|
|
359
|
+
* Helper to create a sync adapter configuration.
|
|
360
|
+
*/
|
|
361
|
+
declare function syncAdapter<T>(config: SyncAdapter<T>): SyncAdapter<T>;
|
|
362
|
+
|
|
363
|
+
type RouteLoaderFn<T = unknown> = (context: {
|
|
364
|
+
params: Record<string, string>;
|
|
365
|
+
path: string;
|
|
366
|
+
}, info: {
|
|
367
|
+
signal: AbortSignal;
|
|
368
|
+
}) => Promise<T>;
|
|
369
|
+
interface LoaderRoute {
|
|
370
|
+
loader?: RouteLoaderFn;
|
|
371
|
+
path: string;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Execute a route loader and wrap its result in a reactive Resource.
|
|
375
|
+
*/
|
|
376
|
+
declare function executeLoader<T>(loader: RouteLoaderFn<T>, context: {
|
|
377
|
+
params: Record<string, string>;
|
|
378
|
+
path: string;
|
|
379
|
+
}, options?: ResourceOptions<T>): Resource<T>;
|
|
380
|
+
/**
|
|
381
|
+
* Access loader data from within a route component.
|
|
382
|
+
* Must be called inside a component rendered by a route with a loader.
|
|
383
|
+
*/
|
|
384
|
+
declare function loaderData<T = unknown>(): {
|
|
385
|
+
data: () => T | undefined;
|
|
386
|
+
loading: () => boolean;
|
|
387
|
+
error: () => Error | undefined;
|
|
388
|
+
};
|
|
389
|
+
/**
|
|
390
|
+
* Preload a route's data before navigation.
|
|
391
|
+
* Returns a promise that resolves when the loader completes.
|
|
392
|
+
*/
|
|
393
|
+
declare function preloadRoute(route: LoaderRoute, context: {
|
|
394
|
+
params: Record<string, string>;
|
|
395
|
+
path: string;
|
|
396
|
+
}): Promise<unknown>;
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* socket provides a reactive WebSocket connection with auto-reconnect
|
|
400
|
+
* and optional heartbeat support.
|
|
401
|
+
*/
|
|
402
|
+
declare function socket(url: string | (() => string), options?: {
|
|
403
|
+
protocols?: string | string[];
|
|
404
|
+
autoReconnect?: boolean;
|
|
405
|
+
reconnectDelay?: number;
|
|
406
|
+
maxReconnects?: number;
|
|
407
|
+
heartbeat?: {
|
|
408
|
+
interval: number;
|
|
409
|
+
message: string;
|
|
410
|
+
};
|
|
411
|
+
}): {
|
|
412
|
+
data: () => unknown;
|
|
413
|
+
status: () => "connecting" | "open" | "closing" | "closed";
|
|
414
|
+
send: (data: string | ArrayBufferLike | Blob) => void;
|
|
415
|
+
close: () => void;
|
|
416
|
+
dispose: () => void;
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* stream provides reactive Server-Sent Events (SSE) integration.
|
|
421
|
+
* Wraps the EventSource API with reactive state for data, event name, and connection status.
|
|
422
|
+
*/
|
|
423
|
+
declare function stream(url: string, options?: {
|
|
424
|
+
withCredentials?: boolean;
|
|
425
|
+
autoReconnect?: boolean;
|
|
426
|
+
}): {
|
|
427
|
+
data: () => string | null;
|
|
428
|
+
event: () => string | null;
|
|
429
|
+
status: () => "connecting" | "open" | "closed";
|
|
430
|
+
close: () => void;
|
|
431
|
+
dispose: () => void;
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
export { type InfiniteQueryOptions, type InfiniteQueryResult, type LoaderRoute, type MutationOptions, type MutationResult, type OfflineStore, type OfflineStoreOptions, type QueryOptions, type QueryResult, type Resource, type ResourceOptions, type RetryOptions, type RouteLoaderFn, type SyncAdapter, type SyncChange, type SyncResult, calculateDelay, clearQueryCache, debounce, executeLoader, getQueryData, infiniteQuery, invalidateQueries, loaderData, mutation, offlineStore, preloadRoute, previous, query, resource, setQueryData, socket, stream, syncAdapter, throttle, withRetry };
|