@stacksjs/stx 0.2.564 → 0.2.566

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.
Files changed (119) hide show
  1. package/dist/{chunk-ezdsaxbb.js → chunk-01s01ten.js} +3 -3
  2. package/dist/chunk-04qvjcsr.js +2 -0
  3. package/dist/{chunk-7phshjwf.js → chunk-125rc958.js} +1 -1
  4. package/dist/{chunk-f1z9ekjh.js → chunk-18270qgd.js} +2 -2
  5. package/dist/{chunk-a9q8c4pm.js → chunk-1hrj0t0j.js} +8 -8
  6. package/dist/{chunk-wxkphrnt.js → chunk-2ernwctg.js} +3 -3
  7. package/dist/chunk-2yypassp.js +2 -0
  8. package/dist/{chunk-qyq7edq6.js → chunk-325p135t.js} +1 -1
  9. package/dist/{chunk-f5n26rq9.js → chunk-36aj0yzt.js} +1 -1
  10. package/dist/{chunk-m6826w3k.js → chunk-375skn32.js} +1 -1
  11. package/dist/{chunk-rqc62964.js → chunk-3hkv4e7t.js} +1 -1
  12. package/dist/chunk-4mmdpb46.js +2 -0
  13. package/dist/{chunk-ec8k75ep.js → chunk-4zb2ga7p.js} +2 -2
  14. package/dist/{chunk-4bhjt6xn.js → chunk-55hfvmvv.js} +5 -5
  15. package/dist/{chunk-0897e87r.js → chunk-5grx48s2.js} +1 -1
  16. package/dist/{chunk-4ct7a53d.js → chunk-5s555c1r.js} +3 -3
  17. package/dist/chunk-5ytg0wbc.js +2 -0
  18. package/dist/{chunk-97614ghv.js → chunk-6sf4v894.js} +2 -2
  19. package/dist/{chunk-zycahp89.js → chunk-6yn90mq9.js} +1 -1
  20. package/dist/chunk-7d2vyre0.js +2 -0
  21. package/dist/{chunk-vjx8gtfk.js → chunk-8afnq4qx.js} +2 -2
  22. package/dist/{chunk-658paz71.js → chunk-8cpqy9ea.js} +1506 -1506
  23. package/dist/chunk-8d788kvt.js +2 -0
  24. package/dist/{chunk-m6zmvcq2.js → chunk-8txqk9nq.js} +1 -1
  25. package/dist/{chunk-hb95ah88.js → chunk-90qywh24.js} +3 -3
  26. package/dist/chunk-bdhtq3vs.js +2 -0
  27. package/dist/chunk-brnapchc.js +2 -0
  28. package/dist/{chunk-7cfpb2n8.js → chunk-c765y72x.js} +2 -2
  29. package/dist/{chunk-p47kzj6s.js → chunk-d1mqedk0.js} +1 -1
  30. package/dist/{chunk-0fv4x8fn.js → chunk-da9avgd9.js} +1 -1
  31. package/dist/{chunk-8b6mp92r.js → chunk-dmf1jmge.js} +2 -2
  32. package/dist/chunk-e3njkecx.js +2 -0
  33. package/dist/{chunk-86cnpvf4.js → chunk-efzc1nw8.js} +1 -1
  34. package/dist/{chunk-ymcsz527.js → chunk-ev3qnr9q.js} +2 -2
  35. package/dist/{chunk-5zxb7dsf.js → chunk-fm4w1r9e.js} +1 -1
  36. package/dist/{chunk-m7h6wx3r.js → chunk-g1epk002.js} +1 -1
  37. package/dist/chunk-hmk7z0z6.js +2 -0
  38. package/dist/{chunk-q0xcf4zq.js → chunk-hn105xy3.js} +1 -1
  39. package/dist/chunk-jq079mrx.js +2 -0
  40. package/dist/{chunk-kj4fpfjj.js → chunk-jr149mmp.js} +1 -1
  41. package/dist/{chunk-4ga3g8xc.js → chunk-kwxy0e3r.js} +1 -1
  42. package/dist/chunk-kza3nxr0.js +2 -0
  43. package/dist/chunk-ma2yh8zc.js +63 -0
  44. package/dist/chunk-mahv855w.js +2 -0
  45. package/dist/{chunk-rxvnfge3.js → chunk-mb59b499.js} +4 -4
  46. package/dist/{chunk-w9157aaz.js → chunk-mm1vvk49.js} +1 -1
  47. package/dist/{chunk-d7w1n5jm.js → chunk-mt8sew7a.js} +5 -5
  48. package/dist/chunk-n2g9mj2h.js +2 -0
  49. package/dist/{chunk-m3drjrkh.js → chunk-n2nha538.js} +1 -1
  50. package/dist/{chunk-1dfd95ev.js → chunk-n6va14bt.js} +1 -1
  51. package/dist/chunk-nebw444s.js +2 -0
  52. package/dist/{chunk-hdswffnj.js → chunk-nm0y4qjg.js} +1 -1
  53. package/dist/chunk-nmt7kw0e.js +2 -0
  54. package/dist/{chunk-46195rpy.js → chunk-pzasxhwz.js} +1 -1
  55. package/dist/chunk-qajc13zq.js +2 -0
  56. package/dist/chunk-qtnqmw1n.js +2 -0
  57. package/dist/chunk-r3zdgeah.js +2 -0
  58. package/dist/chunk-r5htacg5.js +2 -0
  59. package/dist/{chunk-fh4vpewx.js → chunk-rf2rwddd.js} +1 -1
  60. package/dist/{chunk-9jvzz9pr.js → chunk-s1xxkzc9.js} +4 -4
  61. package/dist/chunk-s833fbvf.js +2 -0
  62. package/dist/chunk-sgvszh9s.js +2 -0
  63. package/dist/{chunk-et82hw8n.js → chunk-ss78553t.js} +1 -1
  64. package/dist/chunk-t5r3s1wj.js +2 -0
  65. package/dist/{chunk-jh9ajakd.js → chunk-tc01jkfc.js} +1 -1
  66. package/dist/{chunk-8sfv1h98.js → chunk-tfeenp4h.js} +4 -4
  67. package/dist/chunk-tjprg6kq.js +2 -0
  68. package/dist/{chunk-30wqqwbn.js → chunk-tsmbstj6.js} +1 -1
  69. package/dist/{chunk-vc6dn0jf.js → chunk-vtz9empe.js} +1 -1
  70. package/dist/{chunk-ztfvrpp6.js → chunk-wa6nzq5b.js} +1 -1
  71. package/dist/{chunk-tq28tg3k.js → chunk-wm11csdm.js} +1 -1
  72. package/dist/{chunk-pjgzqz07.js → chunk-wwn9dh6p.js} +1 -1
  73. package/dist/{chunk-4aw3whbc.js → chunk-xw8kzm6b.js} +2104 -2104
  74. package/dist/chunk-ytdzgctp.js +2 -0
  75. package/dist/{chunk-yje1skpw.js → chunk-z2n1rtj5.js} +1 -1
  76. package/dist/cli.js +11 -11
  77. package/dist/craft-entry.js +2 -2
  78. package/dist/craft.js +2 -2
  79. package/dist/database.js +2 -2
  80. package/dist/native/components/primitives.d.ts +20 -4
  81. package/dist/native/index.d.ts +3 -0
  82. package/dist/native/primitives/Map.stx +2 -1
  83. package/dist/native/prop-names.js +3 -0
  84. package/dist/native/runtime/craft-bridge.js +31 -12
  85. package/dist/native/runtime/craft.d.ts +7 -5
  86. package/dist/pwa.js +1 -1
  87. package/dist/ssg.js +2 -2
  88. package/dist/stx.d.ts +1 -1028
  89. package/dist/variable-extractor.js +2 -2
  90. package/package.json +6 -5
  91. package/src/composables/use-mouse.ts +438 -0
  92. package/stx.d.ts +2 -0
  93. package/dist/chunk-1g4t7df6.js +0 -63
  94. package/dist/chunk-1k38dc96.js +0 -2
  95. package/dist/chunk-4ss6b94k.js +0 -2
  96. package/dist/chunk-592xm851.js +0 -2
  97. package/dist/chunk-5adcz47v.js +0 -2
  98. package/dist/chunk-7bqkgjxv.js +0 -2
  99. package/dist/chunk-8218m54a.js +0 -2
  100. package/dist/chunk-b7yvq1kw.js +0 -2
  101. package/dist/chunk-bhyrzt2n.js +0 -2
  102. package/dist/chunk-d80xsgse.js +0 -2
  103. package/dist/chunk-e7ddshxz.js +0 -2
  104. package/dist/chunk-eh6n83az.js +0 -2
  105. package/dist/chunk-enb8dpkt.js +0 -2
  106. package/dist/chunk-fh8q5rnd.js +0 -2
  107. package/dist/chunk-fm5tm1b7.js +0 -2
  108. package/dist/chunk-gkq300a7.js +0 -2
  109. package/dist/chunk-h5jpbxda.js +0 -2
  110. package/dist/chunk-jzmtpjns.js +0 -2
  111. package/dist/chunk-m1bczftm.js +0 -2
  112. package/dist/chunk-nkarb6fg.js +0 -2
  113. package/dist/chunk-qc66nfp7.js +0 -2
  114. package/dist/chunk-sg2bn15n.js +0 -2
  115. package/dist/chunk-sn98t7ef.js +0 -2
  116. package/dist/chunk-sz243f3v.js +0 -2
  117. package/dist/chunk-t2ec3fek.js +0 -2
  118. package/dist/chunk-xnfjemzj.js +0 -2
  119. /package/dist/{chunk-nd7vkt4w.js → chunk-m8qgr307.js} +0 -0
package/dist/stx.d.ts CHANGED
@@ -1,1028 +1 @@
1
- /**
2
- * STX Ambient Type Declarations
3
- *
4
- * This file is shipped with the @stacksjs/stx package and referenced from
5
- * the package's main types entry. When stx is installed, TypeScript picks
6
- * these declarations up automatically — apps do NOT need to write their own
7
- * stx.d.ts workaround for runtime globals.
8
- *
9
- * What's declared here:
10
- * 1. Module declarations for `*.stx` and `*.md` imports
11
- * 2. Runtime globals injected by the stx signals runtime into <script client>
12
- * blocks (signals, lifecycle, stores, composables, head, routing, etc.)
13
- * 3. The `window.stx` registry interface
14
- *
15
- * Source of truth for the auto-imported global list:
16
- * packages/stx/src/client-script.ts → STX_AUTO_IMPORTS
17
- * packages/stx/src/signals.ts → window.stx = { ... }
18
- */
19
-
20
- /// <reference path="./browser-auto-imports.d.ts" />
21
-
22
- // ============================================================================
23
- // Module declarations
24
- // ============================================================================
25
-
26
- // Allow importing .stx files
27
- declare module '*.stx'
28
-
29
- // Allow importing .md files with frontmatter
30
- declare module '*.md' {
31
- const content: string
32
- const data: Record<string, any>
33
- export default content
34
- export { data }
35
- }
36
-
37
- // ============================================================================
38
- // Signal types
39
- // ============================================================================
40
-
41
- interface StxSignal<T> {
42
- (): T
43
- value: T
44
- set: (value: T) => void
45
- update: (fn: (current: T) => T) => void
46
- subscribe: (cb: (value: T) => void) => () => void
47
- readonly _isSignal: true
48
- }
49
-
50
- interface StxDerivedSignal<T> {
51
- (): T
52
- readonly value: T
53
- // Derived signals carry `_isDerived: true` (distinguishes them from state
54
- // signals, which carry `_isSignal: true`). The two branches are exposed
55
- // separately as `isSignal()` / `isDerived()`. Surfaced by the dual-impl
56
- // parity test — both implementations agree on this contract.
57
- readonly _isDerived: true
58
- }
59
-
60
- interface StxRef<T> {
61
- value: T
62
- }
63
-
64
- type StxCleanup = () => void
65
-
66
- // ============================================================================
67
- // Signals (modern reactivity)
68
- // ============================================================================
69
-
70
- declare function state<T>(_initial: T): StxSignal<T>
71
- declare function derived<T>(_compute: () => T): StxDerivedSignal<T>
72
- declare function effect(_fn: () => void | StxCleanup): StxCleanup
73
- declare function batch(_fn: () => void): void
74
- declare function untrack<T>(_value: T | StxSignal<T> | StxDerivedSignal<T>): T
75
- declare function peek<T>(_fn: () => T): T
76
- declare function isSignal(_value: unknown): value is StxSignal<unknown>
77
- declare function isDerived(_value: unknown): value is StxDerivedSignal<unknown>
78
-
79
- // ============================================================================
80
- // Lifecycle
81
- // ============================================================================
82
-
83
- /**
84
- * A lifecycle hook may be `async`.
85
- *
86
- * `onMount(async () => { rows.set(await load()) })` is the documented way to
87
- * fetch a component's initial data - it is the second JSDoc example on both
88
- * `onMount` implementations - and the runtime has always awaited nothing and
89
- * simply let the promise run. These declarations left the promise out of the
90
- * return union, so every async `onMount` in a real app was a type error
91
- * against a call that works.
92
- *
93
- * Only a synchronous return can be a cleanup function: the runtime registers
94
- * it before the next hook runs. So a promise resolves to `void`.
95
- */
96
- declare function onMount(_fn: () => void | StxCleanup | Promise<void>): void
97
- declare function onDestroy(_fn: () => void | Promise<void>): void
98
- declare function onBeforeMount(_fn: () => void | Promise<void>): void
99
- declare function onMounted(_fn: () => void | StxCleanup | Promise<void>): void
100
- declare function onBeforeUnmount(_fn: () => void | Promise<void>): void
101
- declare function onUnmounted(_fn: () => void | Promise<void>): void
102
- // onBeforeUpdate / onUpdated / onErrorCaptured are NOT declared: they exist in
103
- // reactivity.ts and composition-api.ts but have no client-runtime counterpart,
104
- // so declaring them promised a global that resolved to undefined (#1804).
105
-
106
- // ============================================================================
107
- // Template refs
108
- // ============================================================================
109
-
110
- /** Stable per-component id, unique across instances. */
111
- declare function useId(_prefix?: string): string
112
- /**
113
- * Signal tracking a parent-driven `:prop="signal()"` attribute on the
114
- * component's root element. One-way: parent to child.
115
- */
116
- declare function useReactiveProp<T = unknown>(
117
- _name: string,
118
- _defaultValue?: T,
119
- _options?: { parse?: (_value: string) => T },
120
- ): StxSignal<T>
121
- interface StxModelOptions<T> {
122
- default?: T
123
- parse?: (value: string) => T
124
- get?: (value: T) => T
125
- set?: (value: T, modifiers: Readonly<Record<string, boolean>>) => T
126
- }
127
- interface StxModelSignal<T> extends StxSignal<T> {
128
- readonly modifiers: Readonly<Record<string, boolean>>
129
- input(value: T): void
130
- change(value: T): void
131
- }
132
- declare function useModel<T>(options: StxModelOptions<T> & { default: T }): StxModelSignal<T>
133
- declare function useModel<T>(name: string, options: StxModelOptions<T> & { default: T }): StxModelSignal<T>
134
- declare function useModel<T = unknown>(name?: string, options?: StxModelOptions<T>): StxModelSignal<T | undefined>
135
- declare function useModel<T = unknown>(options?: StxModelOptions<T>): StxModelSignal<T | undefined>
136
- /**
137
- * A template ref. Read it however the surrounding code reads things: `ref()`
138
- * like every other stx accessor, or `ref.current` / `ref.value` for the
139
- * Vue- and React-shaped call sites.
140
- */
141
- interface StxTemplateRef<T> {
142
- (): T | null
143
- readonly current: T | null
144
- readonly value: T | null
145
- }
146
- declare function useRef<T = HTMLElement>(_name: string): StxTemplateRef<T>
147
-
148
- // ============================================================================
149
- // Routing / navigation
150
- // ============================================================================
151
-
152
- interface StxNavigateOptions {
153
- /** Replace the current history entry instead of pushing a new one. */
154
- replace?: boolean
155
- /** Bypass the SPA router and perform a full document load. */
156
- reload?: boolean
157
- }
158
-
159
- /**
160
- * Navigate via the SPA router.
161
- *
162
- * The second argument is deliberately NOT typed to also accept a boolean. The
163
- * legacy positional `forceReload` boolean still works at runtime — it was the
164
- * shape that actually shipped — but keeping it out of the type means nothing
165
- * that type-checks today changes meaning (#1807).
166
- */
167
- declare function navigate<T extends string>(
168
- _url: T & import('@stacksjs/stx').CheckHref<T>,
169
- _options?: StxNavigateOptions,
170
- ): void
171
- declare function goBack(): void
172
- declare function goForward(): void
173
-
174
- /**
175
- * Re-run the current route against the server and swap the result, without a
176
- * document load. Use after a mutation that changed server-rendered content.
177
- */
178
- declare function refresh(): Promise<boolean>
179
-
180
- /**
181
- * Expire one cached route so the next visit re-fetches it. Defaults to the
182
- * current path.
183
- */
184
- declare function invalidateRoute(_url?: string): void
185
- declare function useRoute(): {
186
- path: string
187
- params: Record<string, string>
188
- query: Record<string, string>
189
- hash: string
190
- }
191
- declare function setRouteParams(_params: Record<string, string>): void
192
-
193
- /**
194
- * Reactive access to the current route's dynamic segments.
195
- *
196
- * Published on `window.stx` by 5daaba1f9b but never added to the auto-imported
197
- * list, so it was reachable only as `window.stx.useRouteParams()` — exactly the
198
- * authoring-surface gap in #1846.
199
- */
200
- declare function useRouteParams(): StxSignal<Record<string, string>>
201
- /** One dynamic segment, as a signal. */
202
- declare function useRouteParam(_name: string, _defaultValue?: string): StxSignal<string>
203
- /** How a search-param mutation is written to session history (#1825). */
204
- interface StxSearchParamsCommitOptions {
205
- /** Replace the current history entry instead of pushing a new one. */
206
- replace?: boolean
207
- }
208
-
209
- /**
210
- * Reactive access to the URL query string.
211
- *
212
- * The declaration was wrong in both directions (#1806): it promised `delete`
213
- * and `has`, which did not exist at runtime, and omitted `setAll` and `data`,
214
- * which did. `delete`/`has` are now implemented rather than dropped; `get`
215
- * returns `undefined` for a missing key, not `null`, which is what the runtime
216
- * and the docs have always said.
217
- */
218
- declare function useSearchParams(): {
219
- /** The backing signal — read it to make a binding reactive to the query. */
220
- data: StxSignal<Record<string, string>>
221
- get: (_key: string) => string | undefined
222
- has: (_key: string) => boolean
223
- /** Set a param. Pushes a history entry unless `{ replace: true }` is passed. */
224
- set: (_key: string, _value: string, _options?: StxSearchParamsCommitOptions) => void
225
- /**
226
- * Remove a param. Pushes a history entry unless `{ replace: true }` is passed.
227
- *
228
- * CONSUMING a one-shot param — an OAuth callback result, `?checkout=success`,
229
- * a flash token — needs `{ replace: true }`. Under the default push, the URL
230
- * that still carries the param becomes the previous history entry, so Back
231
- * replays the callback and re-runs whatever consuming it triggered (#1825).
232
- */
233
- delete: (_key: string, _options?: StxSearchParamsCommitOptions) => void
234
- /** Set several params. Pushes a history entry unless `{ replace: true }` is passed. */
235
- setAll: (_values: Record<string, string>, _options?: StxSearchParamsCommitOptions) => void
236
- }
237
-
238
- // ============================================================================
239
- // Data fetching
240
- // ============================================================================
241
-
242
- /** How one run of a request should behave. */
243
- interface StxRefetchOptions {
244
- /**
245
- * Refresh without touching `loading` or clearing the current error.
246
- *
247
- * A poll refreshes data that is already on screen, so driving the first-load
248
- * state from it puts a spinner over a populated view on every tick — the
249
- * reason a polling view could not use these primitives at all (#1929). Bind
250
- * `isFetching` for a subtle in-flight indicator instead.
251
- */
252
- background?: boolean
253
- }
254
-
255
- interface StxFetchResult<T> {
256
- data: StxSignal<T | null>
257
- /** True while a first-load request is in flight. A background one leaves it alone. */
258
- loading: StxSignal<boolean>
259
- /** True while ANY request is in flight, background ones included. */
260
- isFetching: StxSignal<boolean>
261
- error: StxSignal<Error | null>
262
- refetch: (_options?: StxRefetchOptions) => Promise<void>
263
- }
264
-
265
- /*
266
- * `useQuery` returns more than `useFetch` does, and declaring one shape for
267
- * both hid it: `isStale` and `invalidate` existed at runtime and were invisible
268
- * to the type, so reading either was an error on a value that was really there
269
- * (#1929). Extending rather than widening the shared interface, because the
270
- * inverse mistake is worse — declaring `invalidate` on `useFetch` would
271
- * type-check a call to something that is undefined at runtime.
272
- */
273
- interface StxQueryResult<T> extends StxFetchResult<T> {
274
- /** True when cached data is on screen while a revalidation runs. */
275
- isStale: StxSignal<boolean>
276
- /** Drop this key from the cache and refetch. */
277
- invalidate: (_options?: StxRefetchOptions) => Promise<void>
278
- }
279
-
280
- interface StxMutationResult<T> {
281
- data: StxSignal<T | null>
282
- loading: StxSignal<boolean>
283
- error: StxSignal<Error | null>
284
- mutate: (body?: unknown) => Promise<T>
285
- }
286
-
287
- declare function useFetch<T = any>(_url: string, _options?: any): StxFetchResult<T>
288
- /** Server-only, keyed JSON data exposed to this render's client hydration. */
289
- declare function useServerData<T>(_key: string, _loader: () => T | Promise<T>): Promise<T>
290
- /** Clear a hydration snapshot without changing existing signals. */
291
- declare function clearServerData(_key?: string): void
292
- declare function useQuery<T = any>(_url: string, _options?: any): StxQueryResult<T>
293
- declare function useMutation<T = any>(_url: string, _options?: any): StxMutationResult<T>
294
-
295
- /** Context handed to a request interceptor. Mutate it; the return is ignored. */
296
- interface StxFetchRequestContext {
297
- /** Which primitive made the call: 'useFetch' | 'useQuery' | 'useMutation'. */
298
- source: string
299
- /** Reassignable, so a hook can prefix a baseURL. */
300
- url: string
301
- /** `headers` is normalised to an object before the hook runs. */
302
- options: RequestInit & { headers: Record<string, string> }
303
- }
304
-
305
- /** Context handed to a response interceptor. */
306
- interface StxFetchResponseContext extends StxFetchRequestContext {
307
- response: Response
308
- }
309
-
310
- /**
311
- * Context handed to an error interceptor. `response` is the non-ok Response, or
312
- * null when the fetch itself threw (a network failure); `error` is set only in
313
- * the latter case.
314
- */
315
- interface StxFetchErrorContext extends StxFetchRequestContext {
316
- response: Response | null
317
- error: Error | null
318
- }
319
-
320
- /**
321
- * Install request/response interceptors for every stx data primitive.
322
- *
323
- * All three funnel through one internal fetch, so a single pair of hooks
324
- * carries an auth header or observes a 401 across `useFetch`, `useQuery` and
325
- * `useMutation`. Calling this again REPLACES the hooks rather than adding to
326
- * them, so a re-evaluated module cannot install the same interceptor twice.
327
- *
328
- * `onResponseError` fires for a non-ok response and for a thrown fetch. Return
329
- * a Response to replace the failed one — the shape a 401 -> refresh -> retry
330
- * takes: refresh the token, re-issue the request with a plain `fetch()` (not
331
- * this data layer, so it does not re-enter the hook), and return that Response.
332
- * Return nothing to let the original error stand.
333
- */
334
- declare function configureFetch(_config: {
335
- onRequest?: (_ctx: StxFetchRequestContext) => void | Promise<void>
336
- onResponse?: (_ctx: StxFetchResponseContext) => void | Promise<void>
337
- onResponseError?: (_ctx: StxFetchErrorContext) => void | Response | Promise<void | Response>
338
- /**
339
- * Double-submit CSRF. By default every same-origin POST/PUT/PATCH/DELETE
340
- * repeats the `X-CSRF-Token` cookie in an `X-CSRF-Token` header, which is
341
- * what a Stacks server checks. Rename either side, or pass `false` to stop.
342
- * Unlike the hooks, this persists across calls that do not mention it.
343
- */
344
- csrf?: false | {
345
- cookie?: string
346
- header?: string
347
- /**
348
- * A same-origin GET that sets the CSRF cookie, requested once before an
349
- * unsafe request finds no cookie. Needed on a page served from a CDN
350
- * cache, which cannot carry Set-Cookie. Any safe Stacks route seeds it.
351
- */
352
- prime?: string
353
- }
354
- }): void
355
-
356
- declare function useOptimistic<T = any, A = any>(
357
- _base: StxSignal<T> | (() => T) | T,
358
- _reducer: (_current: T, _action: A) => T,
359
- ): [StxSignal<T>, (_action: A, _settleWhen?: PromiseLike<unknown>) => () => void]
360
-
361
- // ============================================================================
362
- // DOM utilities
363
- // ============================================================================
364
-
365
- /**
366
- * Options the runtime reads, including the target it binds to.
367
- *
368
- * The target travels HERE rather than in a leading parameter, because that is
369
- * what the implementation does: `var target = (options && options.target) || window`.
370
- */
371
- interface StxEventListenerOptions {
372
- /** Element, selector, or document/window. Defaults to `window`. */
373
- target?: Window | Document | HTMLElement | string | null
374
- capture?: boolean
375
- passive?: boolean
376
- once?: boolean
377
- }
378
-
379
- /*
380
- * Event first, then handler, then options (stacksjs/stx#1923).
381
- *
382
- * This was declared target-first while the runtime has always been
383
- * event-first, so the two disagreed in the worst possible direction: `_target`
384
- * accepted `string`, so the CORRECT call got as far as reading 'keydown' as a
385
- * selector before failing on the handler, and an author who trusted the type
386
- * and added a target wrote `useEventListener(window, 'keydown', fn)` — which
387
- * binds an event named "window" with the string 'keydown' as its handler, and
388
- * silently attaches nothing.
389
- *
390
- * `browser-composables.ts` had it right all along; the package shipped two
391
- * declarations of one name with different arities and the registry got the
392
- * wrong one. Same shape as the `reactive` split: one name, two conventions, and
393
- * no way for the call site to tell which it has.
394
- */
395
- declare function useEventListener<K extends keyof WindowEventMap>(
396
- _event: K,
397
- _handler: (event: WindowEventMap[K]) => void,
398
- _options?: StxEventListenerOptions,
399
- ): StxCleanup
400
- declare function useEventListener(
401
- _event: string,
402
- _handler: (event: Event) => void,
403
- _options?: StxEventListenerOptions,
404
- ): StxCleanup
405
- declare function useScrollLock(
406
- _target?: HTMLElement | null | { current?: HTMLElement | null, value?: HTMLElement | null } | (() => HTMLElement | null | undefined),
407
- ): StxSignal<boolean>
408
- declare function useClickOutside(_target: HTMLElement | StxRef<HTMLElement | null> | string | null, _handler: (event: MouseEvent) => void): StxCleanup
409
- declare function useFocus(_target: HTMLElement | StxRef<HTMLElement | null> | string | null): { focused: StxSignal<boolean>, focus: () => void, blur: () => void }
410
-
411
- // ============================================================================
412
- // Timers / scheduling
413
- // ============================================================================
414
-
415
- declare function useDebounce<T extends (..._args: any[]) => any>(_fn: T, _delay: number): T
416
- declare const useDebounceFn: typeof useDebounce
417
- declare function useDebouncedValue<T>(_value: StxSignal<T>, _delay: number): StxSignal<T>
418
- declare const refDebounced: typeof useDebouncedValue
419
- declare function useThrottle<T extends (..._args: any[]) => any>(_fn: T, _delay: number): T
420
- declare const useThrottleFn: typeof useThrottle
421
- interface StxIntervalOptions {
422
- /** Tick once on start/resume instead of waiting out the first interval. */
423
- immediate?: boolean
424
- /** Gate ticks. `false`, or a function returning false, skips them entirely. */
425
- enabled?: boolean | (() => boolean)
426
- /** Skip ticks while `document.hidden`. */
427
- whileVisible?: boolean
428
- }
429
-
430
- interface StxIntervalControls {
431
- /**
432
- * Ticks elapsed. A plain number — read it, do not call it. It is not a
433
- * signal and an `effect` cannot track it; use `subscribe` to react.
434
- */
435
- readonly counter: number
436
- pause: () => void
437
- resume: () => void
438
- reset: () => void
439
- /** Runs on each tick with the new count. Returns an unsubscribe. */
440
- subscribe: (_fn: (_count: number) => void) => () => void
441
- }
442
-
443
- /**
444
- * Interval with controls. Both call forms work:
445
- * `useInterval(1000)` for the counter, `useInterval(fn, 1000)` to run something.
446
- *
447
- * There is deliberately no `start`/`stop`/`isActive` here. A declaration of that
448
- * shape shipped for some time and nothing implemented it, so calls against it
449
- * typechecked clean and threw `poll.start is not a function` on mount (#1941).
450
- * `resume`/`pause` are the real names.
451
- */
452
- declare function useInterval(_interval?: number, _options?: StxIntervalOptions): StxIntervalControls
453
- declare function useInterval(_fn: (_count: number) => void, _ms?: number, _options?: StxIntervalOptions): StxIntervalControls
454
- declare function useInterval(_fn: (_count: number) => void, _options?: StxIntervalOptions): StxIntervalControls
455
- declare function useTimeout(_fn: () => void, _ms?: number): {
456
- /** Plain boolean, not a signal. Use `subscribe` to react to it. */
457
- readonly isPending: boolean
458
- start: () => void
459
- stop: () => void
460
- subscribe: (_fn: (_pending: boolean) => void) => () => void
461
- }
462
- declare const useTimeoutFn: typeof useTimeout
463
- declare function nextTick(_fn?: () => void): Promise<void>
464
-
465
- // ============================================================================
466
- // State utilities
467
- // ============================================================================
468
-
469
- declare function useToggle(_initial?: boolean): [StxSignal<boolean>, (value?: boolean) => void]
470
- declare function useCounter(_initial?: number, _options?: { min?: number, max?: number }): {
471
- count: StxSignal<number>
472
- inc: (n?: number) => void
473
- dec: (n?: number) => void
474
- set: (n: number) => void
475
- reset: () => void
476
- }
477
- declare function useAsync<T>(_fn: () => Promise<T>): {
478
- data: StxSignal<T | null>
479
- loading: StxSignal<boolean>
480
- error: StxSignal<Error | null>
481
- execute: () => Promise<T>
482
- }
483
-
484
- // ============================================================================
485
- // Storage
486
- // ============================================================================
487
-
488
- declare function useLocalStorage<T>(_key: string, _defaultValue: T): StxSignal<T>
489
- declare function useSessionStorage<T>(_key: string, _defaultValue: T): StxSignal<T>
490
- /** A value kept between visits (a phone app between launches) in a scope such as the signed-in account; a scope of false keeps nothing. */
491
- declare function keptState<T>(_name: string, _initialValue: T, _options?: { scope?: string | number | false | null }): StxSignal<T>
492
- /** Remove a scope's kept values, or every kept value. */
493
- declare function forgetKeptState(_scope?: string | number | false | null): Promise<void>
494
- /** The account kept state and cached queries belong to when they name no scope. */
495
- declare function setKeptScope(_scope: string | number | false | null | undefined): void
496
- /** Finish writing what is kept (large values are written behind, to IndexedDB). */
497
- declare function flushKeptState(): Promise<void>
498
-
499
- /** Options of `cachedQuery`: see offline/query-cache.ts. */
500
- interface StxCachedQueryOptions<T> {
501
- /** The URL to GET (answered as JSON), or a function giving it. */
502
- url?: string | (() => string | null | undefined)
503
- /** Load the data some other way than a GET of `url`. */
504
- load?: (_context: { force: boolean, url: string | null, signal?: AbortSignal }) => Promise<T>
505
- /** How to send the GET, with current credentials. */
506
- fetch?: (_url: string, _init: RequestInit) => Promise<Response>
507
- /** Whose data this is, as for keptState; a function is read at every load. Default: setKeptScope's. */
508
- scope?: string | number | false | null | (() => string | number | false | null | undefined)
509
- /** How long an answer counts as fresh, ms. Default 0. */
510
- staleTime?: number
511
- initial?: T
512
- transform?: (_raw: any) => T
513
- /** Give up on a request after this long, ms. Default 15000. */
514
- timeoutMs?: number
515
- /** Fetch when created. */
516
- immediate?: boolean
517
- }
518
-
519
- interface StxCachedQuery<T> {
520
- /** The last answer, with writes still waiting in the outbox applied. */
521
- data: StxSignal<T>
522
- loading: StxSignal<boolean>
523
- isFetching: StxSignal<boolean>
524
- error: StxSignal<string | null>
525
- /** When the data shown was fetched (ms); 0 for none. */
526
- updatedAt: StxSignal<number>
527
- /** Fetch when older than staleTime (or always, with force). One request for every caller. */
528
- load: (_force?: boolean) => Promise<T>
529
- /** Fetch now, past every cache. */
530
- refresh: () => Promise<T>
531
- set: (_value: T | ((_current: T) => T)) => void
532
- invalidate: () => void
533
- readonly key: string
534
- }
535
-
536
- /** Data kept per account, shown at once from last time and refreshed behind. Same key, same query. */
537
- declare function cachedQuery<T = any>(_key: string, _options?: StxCachedQueryOptions<T>): StxCachedQuery<T>
538
-
539
- /**
540
- * Options accepted by the auto-imported `useCookie` global.
541
- *
542
- * This describes the CLIENT RUNTIME's cookie composable, which is what a bare
543
- * `useCookie(...)` in a `<script client>` block resolves to. The module export
544
- * `@stacksjs/stx/composables` accepts a slightly wider `expires` (Date, epoch ms
545
- * or parseable string); the runtime calls `.toUTCString()` on it, so only a Date
546
- * works there. See #1710.
547
- */
548
- interface StxCookieOptions {
549
- /** Max age in seconds. */
550
- maxAge?: number
551
- /** Expiration date. */
552
- expires?: Date
553
- /** Cookie path. Defaults to '/'. */
554
- path?: string
555
- /** Cookie domain. */
556
- domain?: string
557
- /** Secure flag. Defaults to true when location.protocol is https:. */
558
- secure?: boolean
559
- /** SameSite attribute. Defaults to 'Lax'. */
560
- sameSite?: 'Strict' | 'Lax' | 'None' | 'strict' | 'lax' | 'none'
561
- /** Value returned when the cookie is absent. Defaults to ''. */
562
- defaultValue?: string
563
- /** Custom encoder. Defaults to encodeURIComponent. */
564
- encode?: (_value: string) => string
565
- /** Custom decoder. Defaults to decodeURIComponent. */
566
- decode?: (_value: string) => string
567
- }
568
-
569
- /**
570
- * Reactive binding to a single cookie (#1808).
571
- *
572
- * Returns a signal, like `useLocalStorage` — writes serialise straight to
573
- * `document.cookie`, and `.set('')` deletes by emitting `max-age=0`.
574
- */
575
- declare function useCookie(_name: string, _options?: StxCookieOptions): StxSignal<string>
576
-
577
- // ============================================================================
578
- // WebSocket
579
- // ============================================================================
580
-
581
- declare function useWebSocket(_url: string, _options?: {
582
- immediate?: boolean
583
- autoReconnect?: boolean | { retries?: number, delay?: number }
584
- onMessage?: (event: MessageEvent) => void
585
- onConnected?: () => void
586
- onDisconnected?: () => void
587
- onError?: (event: Event) => void
588
- }): {
589
- status: StxSignal<'CONNECTING' | 'OPEN' | 'CLOSING' | 'CLOSED'>
590
- data: StxSignal<unknown>
591
- send: (data: string | ArrayBuffer | Blob) => void
592
- open: () => void
593
- close: () => void
594
- ws: WebSocket | null
595
- }
596
-
597
- // ============================================================================
598
- // Color mode
599
- // ============================================================================
600
-
601
- interface StxColorModeOptions {
602
- /** localStorage key holding the preference. @default 'stx-color-mode' */
603
- storageKey?: string
604
- /** Mode used when nothing valid is stored. @default 'auto' */
605
- initialMode?: 'light' | 'dark' | 'auto' | 'system'
606
- /**
607
- * Class applied to `<html>` when dark. @default 'dark'
608
- * Applied alongside `attribute`; pass `null` to opt out of the class.
609
- */
610
- darkClass?: string | null
611
- /** Attribute set to the resolved mode on `<html>`, e.g. 'data-theme'. */
612
- attribute?: string | null
613
- /**
614
- * Spelling written to storage for "follow the system".
615
- * @default whatever is already stored, else 'auto'
616
- */
617
- autoValue?: 'auto' | 'system'
618
- /** Suppress CSS transitions across a mode switch. @default true */
619
- disableTransitions?: boolean
620
- }
621
-
622
- /**
623
- * Omitting the options picks up whatever `app.colorMode` in `stx.config.ts`
624
- * published via the pre-paint boot script (stacksjs/stx#1794), so the storage
625
- * key and attribute don't have to be repeated at the call site.
626
- */
627
- declare function useColorMode(_options?: StxColorModeOptions): {
628
- /** Current resolved mode. */
629
- readonly mode: 'light' | 'dark'
630
- /** User preference, which may be 'auto'. */
631
- readonly preference: 'light' | 'dark' | 'auto'
632
- readonly isDark: boolean
633
- set: (mode: 'light' | 'dark' | 'auto' | 'system') => void
634
- toggle: () => void
635
- subscribe: (fn: (mode: 'light' | 'dark', preference: 'light' | 'dark' | 'auto') => void) => () => void
636
- }
637
- declare function useDark(_options?: StxColorModeOptions): StxSignal<boolean> & {
638
- readonly isDark: boolean
639
- toggle: () => void
640
- }
641
- declare function useMediaQuery(query: string): StxSignal<boolean> & {
642
- readonly matches: boolean
643
- readonly value: boolean
644
- }
645
- declare function usePreferredDark(): ReturnType<typeof useMediaQuery>
646
- declare function usePreferredLight(): ReturnType<typeof useMediaQuery>
647
- declare function usePreferredReducedMotion(): ReturnType<typeof useMediaQuery>
648
- declare function usePreferredContrast(): ReturnType<typeof useMediaQuery>
649
- /** `document.visibilityState`, kept current; `'visible'` or `'hidden'`. */
650
- declare function useDocumentVisibility(): StxSignal<DocumentVisibilityState> & {
651
- readonly value: DocumentVisibilityState
652
- }
653
-
654
- // ============================================================================
655
- // Head / SEO
656
- // ============================================================================
657
-
658
- interface StxHeadConfig {
659
- title?: string
660
- titleTemplate?: string | ((title?: string) => string)
661
- meta?: Array<Record<string, string>>
662
- link?: Array<Record<string, string>>
663
- script?: Array<Record<string, string> & { children?: string }>
664
- style?: Array<Record<string, string> & { children?: string }>
665
- htmlAttrs?: Record<string, string>
666
- bodyAttrs?: Record<string, string>
667
- }
668
-
669
- interface StxSeoMetaConfig {
670
- title?: string
671
- description?: string
672
- keywords?: string
673
- author?: string
674
- ogTitle?: string
675
- ogDescription?: string
676
- ogImage?: string
677
- ogUrl?: string
678
- ogType?: string
679
- twitterCard?: 'summary' | 'summary_large_image' | 'app' | 'player'
680
- twitterTitle?: string
681
- twitterDescription?: string
682
- twitterImage?: string
683
- robots?: string
684
- canonical?: string
685
- }
686
-
687
- declare function useHead(_config: StxHeadConfig): void
688
- declare function useSeoMeta(_config: StxSeoMetaConfig): void
689
- /** No-op on the client; the real one runs at SSR/SSG time. */
690
- declare function definePageMeta(_meta: Record<string, unknown>): void
691
-
692
- // ============================================================================
693
- // Vue-style reactivity (alternative API)
694
- // ============================================================================
695
-
696
- declare function ref<T>(_value: T): StxRef<T>
697
- declare function reactive<T extends object>(_target: T): T
698
- declare function computed<T>(_getter: () => T): StxRef<T>
699
- declare function watch<T>(
700
- _source: (() => T) | StxRef<T> | StxSignal<T>,
701
- _callback: (value: T, oldValue: T) => void,
702
- _options?: { immediate?: boolean, deep?: boolean },
703
- ): StxCleanup
704
- declare function watchEffect(_fn: () => void): StxCleanup
705
- declare function watchMultiple(
706
- _sources: Array<() => unknown>,
707
- _callback: (values: unknown[], oldValues: unknown[]) => void,
708
- _options?: { immediate?: boolean },
709
- ): StxCleanup
710
-
711
- // ============================================================================
712
- // Component definition / composition API
713
- // ============================================================================
714
-
715
- declare function defineProps<T extends Record<string, any> = Record<string, any>>(_definitions?: any): T
716
- declare function withDefaults<T extends Record<string, any>>(_props: T, _defaults: Partial<T>): T
717
- /**
718
- * Two forms, matching the runtime.
719
- *
720
- * The union form names the events and leaves the payload open. The map form
721
- * gives each event a payload tuple, so `emit('view')` with a missing record
722
- * and `emit('view', record, extra)` with a spare one are both errors.
723
- *
724
- * This used to be the union form alone, with a single optional `_payload`.
725
- * That made the documented map form - the one `props.ts` and the composition
726
- * API both implement, and the one the dashboard tables are written in - a
727
- * constraint violation, and made a third argument an arity error even though
728
- * the runtime forwards every argument it is given.
729
- *
730
- * @example
731
- * const emit = defineEmits<'change' | 'close'>()
732
- * @example
733
- * const emit = defineEmits<{ view: [record: Row], remove: [id: number] }>()
734
- */
735
- declare function defineEmits<T extends string = string>(): (_event: T, ..._args: unknown[]) => void
736
- declare function defineEmits<T extends Record<string, unknown[]>>(): <K extends keyof T & string>(_event: K, ..._args: T[K]) => void
737
- declare function defineExpose<T extends Record<string, any>>(_exposed: T): void
738
- declare function defineSlots<T extends Record<string, (..._args: any[]) => any> = Record<string, (..._args: any[]) => any>>(): T
739
- declare function provide<T>(_key: string | symbol, _value: T): void
740
- declare function inject<T>(_key: string | symbol, _defaultValue?: T): T | undefined
741
- declare function useSlots(): Record<string, any>
742
- // getCurrentInstance / useAttrs are NOT declared — composition-api.ts exports
743
- // them for server use; no client-runtime counterpart exists (#1804).
744
- declare function $computed<T>(_getter: () => T): StxRef<T>
745
- declare function $watch<T>(
746
- _source: (() => T) | StxRef<T> | StxSignal<T>,
747
- _callback: (value: T, oldValue: T) => void,
748
- _options?: { immediate?: boolean, deep?: boolean },
749
- ): StxCleanup
750
-
751
- // ============================================================================
752
- // Toast notifications
753
- // ============================================================================
754
-
755
- /*
756
- * Every option `addToast` reads (#1932).
757
- *
758
- * `title`, `id` and `dark` shipped in the runtime for #1913 and none of them
759
- * reached here, so the feature built to unblock a migration could not be called
760
- * from a typechecked file — `stx typecheck` rejected the exact snippet that
761
- * issue was closed with.
762
- *
763
- * `test/signals/toast-declaration-drift.test.ts` now reads the option names out
764
- * of the runtime and fails if this list falls behind again. Adding an option
765
- * here without the runtime reading it fails too: a documented option that does
766
- * nothing is the quieter half of the same problem.
767
- */
768
- interface StxToastOptions {
769
- /** Auto-dismiss duration in ms. 0 = persistent. Default: 3000 */
770
- duration?: number
771
- /** Heading rendered above the message, in bold. */
772
- title?: string
773
- /**
774
- * Semantic key. A second toast with the same id REPLACES the first in place
775
- * rather than stacking, and `dismiss(id)` ends it — so a persistent
776
- * "Publishing…" toast and the call that clears it need not thread the numeric
777
- * handle between them.
778
- */
779
- id?: string | number
780
- /**
781
- * Force the dark or light palette. Omitted, it follows the document — the
782
- * `dark` class, then `data-theme` / `data-color-mode`, then the OS setting.
783
- */
784
- dark?: boolean
785
- }
786
-
787
- interface StxToast {
788
- /** Show a success toast (green) */
789
- success: (message: string, options?: StxToastOptions) => number
790
- /** Show an error toast (red) */
791
- error: (message: string, options?: StxToastOptions) => number
792
- /** Show an info toast (blue) */
793
- info: (message: string, options?: StxToastOptions) => number
794
- /** Show a warning toast (yellow) */
795
- warning: (message: string, options?: StxToastOptions) => number
796
- /**
797
- * Dismiss a toast, or all of them if nothing is given.
798
- *
799
- * Takes the semantic `id` the toast was created with, or the numeric handle
800
- * these methods return. The runtime branches on which it got, so a caller does
801
- * not have to know which kind it is holding — this used to accept `number`
802
- * only, which made replace-by-id unreachable from a typechecked call site.
803
- */
804
- dismiss: (id?: string | number) => void
805
- }
806
-
807
- declare const toast: StxToast
808
-
809
- // ============================================================================
810
- // Modal system
811
- // ============================================================================
812
-
813
- interface StxModal {
814
- /** Open a modal by its id */
815
- open: (id: string) => void
816
- /** Close a modal by its id */
817
- close: (id: string) => void
818
- /** Toggle a modal by its id */
819
- toggle: (id: string) => void
820
- }
821
-
822
- declare const modal: StxModal
823
-
824
- // ============================================================================
825
- // Drawer system
826
- // ============================================================================
827
-
828
- interface StxDrawer {
829
- /** Open a drawer by its id */
830
- open: (id: string) => void
831
- /** Close a drawer by its id */
832
- close: (id: string) => void
833
- /** Toggle a drawer by its id */
834
- toggle: (id: string) => void
835
- }
836
-
837
- declare const drawer: StxDrawer
838
-
839
- // ============================================================================
840
- // Alert & Confirm dialogs
841
- // ============================================================================
842
-
843
- interface StxDialogOptions {
844
- /** Dialog title displayed above the message */
845
- title?: string
846
- /** Icon type: 'info' | 'warning' | 'error' | 'success' | 'question' */
847
- type?: 'info' | 'warning' | 'error' | 'success' | 'question'
848
- /** Text for the confirm/OK button (default: 'OK') */
849
- confirmText?: string
850
- /** Text for the cancel button — confirm only (default: 'Cancel') */
851
- cancelText?: string
852
- }
853
-
854
- /** Styled replacement for window.alert(). Returns a Promise that resolves when dismissed. */
855
- declare function stxAlert(_message: string, _options?: StxDialogOptions): Promise<void>
856
-
857
- /** Styled replacement for window.confirm(). Returns a Promise<boolean>. */
858
- declare function stxConfirm(_message: string, _options?: StxDialogOptions): Promise<boolean>
859
-
860
- // ============================================================================
861
- // Stores (Pinia-inspired, signals-based)
862
- // ============================================================================
863
-
864
- interface StxStorePersistOptions {
865
- pick?: string[]
866
- storage?: 'localStorage' | 'sessionStorage'
867
- key?: string
868
- }
869
-
870
- interface StxStoreOptions {
871
- persist?: boolean | StxStorePersistOptions
872
- }
873
-
874
- declare function defineStore<T>(
875
- _id: string,
876
- _setup: () => T,
877
- _options?: StxStoreOptions,
878
- ): () => T
879
- declare function defineStore<S extends Record<string, any>, G extends Record<string, any>, A extends Record<string, any>>(
880
- _id: string,
881
- _options: {
882
- state?: () => S
883
- getters?: G
884
- actions?: A
885
- persist?: boolean | StxStorePersistOptions
886
- },
887
- ): () => S & G & A
888
- declare function useStore<T = any>(_id: string): T
889
- declare function registerStoresClient(_stores: Record<string, unknown>): void
890
- // createStore / createSelector are exported by state-management.ts for server
891
- // use and `action` has no implementation anywhere; none reaches window.stx, so
892
- // none is declared as an ambient global (#1804).
893
-
894
- // ============================================================================
895
- // JSX runtime (Vue/React style)
896
- // ============================================================================
897
-
898
- // h / Fragment belong to the JSX runtime (jsx-runtime.ts) and are resolved by
899
- // the transform, not destructured off window.stx — so they are not ambient
900
- // globals (#1804). Import them explicitly if you call them directly.
901
-
902
- // ============================================================================
903
- // window.stx registry
904
- // ============================================================================
905
-
906
- interface StxRuntimeRegistry {
907
- // Signals
908
- state: typeof state
909
- derived: typeof derived
910
- effect: typeof effect
911
- batch: typeof batch
912
- untrack: typeof untrack
913
- peek: typeof peek
914
- isSignal: typeof isSignal
915
-
916
- // Lifecycle
917
- onMount: typeof onMount
918
- onDestroy: typeof onDestroy
919
-
920
- // Composables
921
- useFetch: typeof useFetch
922
- clearServerData: typeof clearServerData
923
- useRef: typeof useRef
924
- useQuery: typeof useQuery
925
- useMutation: typeof useMutation
926
- configureFetch: typeof configureFetch
927
- useOptimistic: typeof useOptimistic
928
-
929
- // Routing
930
- navigate: typeof navigate
931
- goBack: typeof goBack
932
- goForward: typeof goForward
933
- refresh: typeof refresh
934
- invalidateRoute: typeof invalidateRoute
935
- useRoute: typeof useRoute
936
- setRouteParams: typeof setRouteParams
937
- useRouteParams: typeof useRouteParams
938
- useRouteParam: typeof useRouteParam
939
- useSearchParams: typeof useSearchParams
940
-
941
- // Composition
942
- provide: typeof provide
943
- defineProps: typeof defineProps
944
- withDefaults: typeof withDefaults
945
- defineEmits: typeof defineEmits
946
- defineExpose: typeof defineExpose
947
- defineSlots: typeof defineSlots
948
-
949
- // Vue compat
950
- ref: typeof ref
951
- reactive: typeof reactive
952
- computed: typeof computed
953
- watch: typeof watch
954
- watchEffect: typeof watchEffect
955
- $computed: typeof $computed
956
- $watch: typeof $watch
957
-
958
- // Utilities
959
- useDebounce: typeof useDebounce
960
- useDebounceFn: typeof useDebounceFn
961
- useDebouncedValue: typeof useDebouncedValue
962
- refDebounced: typeof refDebounced
963
- useThrottle: typeof useThrottle
964
- useThrottleFn: typeof useThrottleFn
965
- useInterval: typeof useInterval
966
- useTimeout: typeof useTimeout
967
- useTimeoutFn: typeof useTimeoutFn
968
- useToggle: typeof useToggle
969
- useCounter: typeof useCounter
970
- useClickOutside: typeof useClickOutside
971
- useFocus: typeof useFocus
972
- useAsync: typeof useAsync
973
- useModel: typeof useModel
974
- useLocalStorage: typeof useLocalStorage
975
- useSessionStorage: typeof useSessionStorage
976
- keptState: typeof keptState
977
- forgetKeptState: typeof forgetKeptState
978
- setKeptScope: typeof setKeptScope
979
- flushKeptState: typeof flushKeptState
980
- cachedQuery: typeof cachedQuery
981
- useEventListener: typeof useEventListener
982
- useScrollLock: typeof useScrollLock
983
- useWebSocket: typeof useWebSocket
984
- useColorMode: typeof useColorMode
985
- useDark: typeof useDark
986
- useHead: typeof useHead
987
- useSeoMeta: typeof useSeoMeta
988
-
989
- // Stores
990
- defineStore: typeof defineStore
991
- useStore: typeof useStore
992
-
993
- // Toast
994
- toast: StxToast
995
-
996
- // Modal
997
- modal: StxModal
998
-
999
- // Drawer
1000
- drawer: StxDrawer
1001
-
1002
- // Dialogs
1003
- alert: typeof stxAlert
1004
- confirm: typeof stxConfirm
1005
-
1006
- // Mount API
1007
- mount: (setupFn: () => any) => void
1008
- mountEl: (selector: string, setupFn: () => any) => void
1009
-
1010
- // Helpers (template helpers — populated by app)
1011
- helpers: Record<string, any>
1012
-
1013
- // Internals (escape hatch)
1014
- [key: string]: any
1015
- }
1016
-
1017
- // Bare global so existing code that references `stx` (without `window.`) still works
1018
- declare const stx: StxRuntimeRegistry
1019
-
1020
- // Augment Window so `window.stx` is typed
1021
- interface Window {
1022
- stx: StxRuntimeRegistry
1023
- __STX_STORES__?: Record<string, any>
1024
- __STX_CURRENT_PROPS__?: Record<string, any>
1025
- __STX_CURRENT_ELEMENT__?: HTMLElement | null
1026
- __stxRouter?: boolean
1027
- __stxRouterConfig?: Record<string, any>
1028
- }
1
+ /// <reference path="../stx.d.ts" />