@kimesh/router-runtime 0.0.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/README.md +3 -0
- package/dist/index.d.mts +1129 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1298 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +50 -0
- package/src/default-app.vue +7 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1129 @@
|
|
|
1
|
+
import * as vue13 from "vue";
|
|
2
|
+
import { App, Component, ComputedRef, InjectionKey, KeepAliveProps, PropType, Ref, TransitionProps, VNode } from "vue";
|
|
3
|
+
import * as vue_router0 from "vue-router";
|
|
4
|
+
import { NavigationFailure, NavigationGuard, NavigationHookAfter, RouteLocationNormalized, RouteLocationNormalized as RouteLocationNormalized$1, RouteLocationNormalizedLoaded, RouteLocationNormalizedLoaded as RouteLocationNormalizedLoaded$1, RouteRecordRaw, RouteRecordRaw as RouteRecordRaw$1, Router, Router as Router$1, onBeforeRouteLeave, onBeforeRouteUpdate, useLink, useRoute, useRouter } from "vue-router";
|
|
5
|
+
import { QueryClient, QueryClientConfig } from "@tanstack/vue-query";
|
|
6
|
+
import { Hookable } from "hookable";
|
|
7
|
+
|
|
8
|
+
//#region src/runtime-types.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Metadata for runtime plugin ordering and identification
|
|
11
|
+
*/
|
|
12
|
+
interface KimeshRuntimePluginMeta {
|
|
13
|
+
/** Plugin name for debugging */
|
|
14
|
+
name?: string;
|
|
15
|
+
/** Execution order: pre runs first, post runs last */
|
|
16
|
+
enforce?: "pre" | "default" | "post";
|
|
17
|
+
/** Numeric order for fine-grained control */
|
|
18
|
+
order?: number;
|
|
19
|
+
/** Wait for these plugins to complete first */
|
|
20
|
+
dependsOn?: string[];
|
|
21
|
+
/** Run in parallel with other parallel plugins */
|
|
22
|
+
parallel?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Navigation context for hooks
|
|
26
|
+
*/
|
|
27
|
+
interface NavigationHookContext {
|
|
28
|
+
to: RouteLocationNormalized$1;
|
|
29
|
+
from: RouteLocationNormalized$1;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Navigation error context
|
|
33
|
+
*/
|
|
34
|
+
interface NavigationErrorHookContext extends NavigationHookContext {
|
|
35
|
+
error: Error;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Navigation after context
|
|
39
|
+
*/
|
|
40
|
+
interface NavigationAfterHookContext extends NavigationHookContext {
|
|
41
|
+
failure?: NavigationFailure;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Runtime hooks available in Kimesh app lifecycle
|
|
45
|
+
*/
|
|
46
|
+
interface KimeshRuntimeHooks {
|
|
47
|
+
"app:created": (app: App) => void | Promise<void>;
|
|
48
|
+
"app:beforeMount": (app: App) => void | Promise<void>;
|
|
49
|
+
"app:mounted": (app: App) => void | Promise<void>;
|
|
50
|
+
"app:error": (err: unknown) => void | Promise<void>;
|
|
51
|
+
"page:start": () => void | Promise<void>;
|
|
52
|
+
"page:finish": () => void | Promise<void>;
|
|
53
|
+
"page:transition:finish": () => void | Promise<void>;
|
|
54
|
+
"page:view-transition:start": (transition: ViewTransition) => void | Promise<void>;
|
|
55
|
+
"navigate:before": (context: NavigationHookContext) => void | false | Promise<void | false>;
|
|
56
|
+
"navigate:after": (context: NavigationAfterHookContext) => void | Promise<void>;
|
|
57
|
+
"navigate:error": (context: NavigationErrorHookContext) => void | Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Runtime config shape (public values only, no SSR)
|
|
61
|
+
*/
|
|
62
|
+
interface RuntimeConfigPublic {
|
|
63
|
+
[key: string]: unknown;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Runtime context available to plugins and composables
|
|
67
|
+
*/
|
|
68
|
+
interface KimeshAppContext {
|
|
69
|
+
vueApp: App;
|
|
70
|
+
router: Router$1;
|
|
71
|
+
queryClient: QueryClient;
|
|
72
|
+
hooks: Hookable<KimeshRuntimeHooks>;
|
|
73
|
+
$config: RuntimeConfigPublic;
|
|
74
|
+
/** Per-layer runtime configs (for layer-aware features like $fetch) */
|
|
75
|
+
$layersConfig: Record<string, Record<string, unknown>>;
|
|
76
|
+
isHydrating: boolean;
|
|
77
|
+
provide: <T>(name: string, value: T) => void;
|
|
78
|
+
runWithContext: <T extends () => unknown>(fn: T) => ReturnType<T>;
|
|
79
|
+
/**
|
|
80
|
+
* Centralized reactive state storage for useState composable
|
|
81
|
+
* CSR-optimized: state exists purely in-memory, no SSR hydration
|
|
82
|
+
*/
|
|
83
|
+
_state: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Return type for plugin setup function
|
|
87
|
+
*/
|
|
88
|
+
interface KimeshRuntimePluginResult<Injections = Record<string, unknown>> {
|
|
89
|
+
provide?: Injections;
|
|
90
|
+
}
|
|
91
|
+
/** Plugin setup return type */
|
|
92
|
+
type PluginSetupReturn<Injections> = void | KimeshRuntimePluginResult<Injections> | Promise<void> | Promise<KimeshRuntimePluginResult<Injections>>;
|
|
93
|
+
/**
|
|
94
|
+
* Runtime plugin function signature
|
|
95
|
+
*/
|
|
96
|
+
interface KimeshRuntimePlugin<Injections = Record<string, unknown>> {
|
|
97
|
+
(app: KimeshAppContext): PluginSetupReturn<Injections>;
|
|
98
|
+
__kimesh_plugin?: true;
|
|
99
|
+
_name?: string;
|
|
100
|
+
meta?: KimeshRuntimePluginMeta;
|
|
101
|
+
hooks?: Partial<KimeshRuntimeHooks>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Object-style runtime plugin definition
|
|
105
|
+
*/
|
|
106
|
+
interface KimeshRuntimePluginDefinition<Injections = Record<string, unknown>> extends KimeshRuntimePluginMeta {
|
|
107
|
+
hooks?: Partial<KimeshRuntimeHooks>;
|
|
108
|
+
setup?: (app: KimeshAppContext) => PluginSetupReturn<Injections>;
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/types.d.ts
|
|
112
|
+
/**
|
|
113
|
+
* User-defined context interface
|
|
114
|
+
* Extend this via declaration merging in your app:
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* declare module '@kimesh/router-runtime' {
|
|
119
|
+
* interface KimeshContext {
|
|
120
|
+
* auth: AuthStore
|
|
121
|
+
* i18n: I18n
|
|
122
|
+
* }
|
|
123
|
+
* }
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
interface KimeshContext {}
|
|
127
|
+
/**
|
|
128
|
+
* Full context available in loaders (built-in + user-defined)
|
|
129
|
+
*/
|
|
130
|
+
interface FullContext extends KimeshContext {
|
|
131
|
+
queryClient: QueryClient;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Injection key for Kimesh context
|
|
135
|
+
*/
|
|
136
|
+
declare const KIMESH_CONTEXT_KEY: InjectionKey<FullContext>;
|
|
137
|
+
/**
|
|
138
|
+
* Param value types for route parameters
|
|
139
|
+
*/
|
|
140
|
+
type ParamValue<isRaw extends boolean> = true extends isRaw ? string | number : string;
|
|
141
|
+
type ParamValueOneOrMore<isRaw extends boolean> = [ParamValue<isRaw>, ...ParamValue<isRaw>[]];
|
|
142
|
+
type ParamValueZeroOrMore<isRaw extends boolean> = true extends isRaw ? ParamValue<isRaw>[] | undefined | null : ParamValue<isRaw>[] | undefined;
|
|
143
|
+
type ParamValueZeroOrOne<isRaw extends boolean> = true extends isRaw ? string | number | null | undefined : string;
|
|
144
|
+
/**
|
|
145
|
+
* Route record info type - populated by generated types
|
|
146
|
+
*/
|
|
147
|
+
interface RouteRecordInfo<Name extends string = string, Path extends string = string, ParamsRaw extends Record<string, unknown> = Record<string, unknown>, Params extends Record<string, unknown> = Record<string, unknown>, Children extends string = never> {
|
|
148
|
+
name: Name;
|
|
149
|
+
path: Path;
|
|
150
|
+
paramsRaw: ParamsRaw;
|
|
151
|
+
params: Params;
|
|
152
|
+
children: Children;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Route named map - populated by generated types
|
|
156
|
+
* This interface is augmented by route-types.d.ts
|
|
157
|
+
*/
|
|
158
|
+
interface RouteNamedMap {}
|
|
159
|
+
/** Get all route names - falls back to string when RouteNamedMap is empty */
|
|
160
|
+
type RouteNames = keyof RouteNamedMap extends never ? string : keyof RouteNamedMap;
|
|
161
|
+
/** Allow both named routes and arbitrary string paths (& {} preserves autocomplete) */
|
|
162
|
+
type RouteLocationRaw = RouteNames | (string & {});
|
|
163
|
+
/** Get route info by name */
|
|
164
|
+
type RouteInfoByName<T extends string> = T extends keyof RouteNamedMap ? RouteNamedMap[T] : RouteRecordInfo<T, T>;
|
|
165
|
+
/** Get raw params for a route name (accepts string | number) */
|
|
166
|
+
type RouteParamsRaw<T extends string> = T extends keyof RouteNamedMap ? RouteNamedMap[T] extends RouteRecordInfo<any, any, infer P, any, any> ? P : Record<string, string | number> : Record<string, string | number>;
|
|
167
|
+
/** Get resolved params for a route name (string only) */
|
|
168
|
+
type RouteParams<T extends string> = T extends keyof RouteNamedMap ? RouteNamedMap[T] extends RouteRecordInfo<any, any, any, infer P, any> ? P : Record<string, string> : Record<string, string>;
|
|
169
|
+
/** Get path for a route name */
|
|
170
|
+
type RoutePath<T extends string> = T extends keyof RouteNamedMap ? RouteNamedMap[T] extends RouteRecordInfo<any, infer P, any, any, any> ? P : string : string;
|
|
171
|
+
/** Check if route has params */
|
|
172
|
+
type HasParams<T extends string> = T extends keyof RouteNamedMap ? keyof RouteParams<T> extends never ? false : true : boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Options for creating a Kimesh app
|
|
175
|
+
*/
|
|
176
|
+
interface CreateKimeshAppOptions {
|
|
177
|
+
/** Root component (usually App.vue or a layout) */
|
|
178
|
+
rootComponent: Component;
|
|
179
|
+
/** Route records array */
|
|
180
|
+
routes: RouteRecordRaw$1[];
|
|
181
|
+
/** Base URL for router */
|
|
182
|
+
base?: string;
|
|
183
|
+
/** History mode */
|
|
184
|
+
history?: "hash" | "web";
|
|
185
|
+
/** Scroll behavior */
|
|
186
|
+
scrollBehavior?: Router$1["options"]["scrollBehavior"];
|
|
187
|
+
/** Query client configuration */
|
|
188
|
+
queryClientConfig?: QueryClientConfig;
|
|
189
|
+
/** Custom context (user-defined) */
|
|
190
|
+
context?: KimeshContext | (() => KimeshContext);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Kimesh App instance
|
|
194
|
+
*/
|
|
195
|
+
interface KimeshApp {
|
|
196
|
+
/** Vue app instance */
|
|
197
|
+
app: App;
|
|
198
|
+
/** Vue Router instance */
|
|
199
|
+
router: Router$1;
|
|
200
|
+
/** Query client instance */
|
|
201
|
+
queryClient: QueryClient;
|
|
202
|
+
/** Kimesh app context (new runtime plugin system) */
|
|
203
|
+
context?: KimeshAppContext;
|
|
204
|
+
/** Mount the app */
|
|
205
|
+
mount(container: string | Element): KimeshApp | Promise<KimeshApp>;
|
|
206
|
+
/** Unmount the app */
|
|
207
|
+
unmount(): void;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Loader context passed to loader functions
|
|
211
|
+
*/
|
|
212
|
+
interface LoaderContext<TParams = Record<string, string>, TSearch = Record<string, unknown>> {
|
|
213
|
+
/** Route params (e.g., { postId: '123' }) */
|
|
214
|
+
params: TParams;
|
|
215
|
+
/** Validated search/query params */
|
|
216
|
+
search: TSearch;
|
|
217
|
+
/** App context (built-in + user-defined) */
|
|
218
|
+
context: FullContext;
|
|
219
|
+
/** AbortSignal for cancellation */
|
|
220
|
+
signal: AbortSignal;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Loader function type
|
|
224
|
+
*/
|
|
225
|
+
type LoaderFn<TParams = Record<string, string>, TSearch = Record<string, unknown>, TData = unknown> = (ctx: LoaderContext<TParams, TSearch>) => Promise<TData> | TData;
|
|
226
|
+
/**
|
|
227
|
+
* Schema interface for validateSearch (compatible with Zod)
|
|
228
|
+
*/
|
|
229
|
+
interface SearchSchema<T = unknown> {
|
|
230
|
+
parse: (input: unknown) => T;
|
|
231
|
+
safeParse?: (input: unknown) => {
|
|
232
|
+
success: boolean;
|
|
233
|
+
data?: T;
|
|
234
|
+
error?: unknown;
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Context passed to route head function
|
|
239
|
+
*/
|
|
240
|
+
interface RouteHeadContext<TParams = Record<string, string>, TLoaderData = unknown> {
|
|
241
|
+
/** Route params extracted from URL */
|
|
242
|
+
params: TParams;
|
|
243
|
+
/** Data returned from route loader */
|
|
244
|
+
loaderData: TLoaderData;
|
|
245
|
+
/** Current route */
|
|
246
|
+
route: RouteLocationNormalizedLoaded$1;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Route head configuration - compatible with @unhead/vue Head type
|
|
250
|
+
*/
|
|
251
|
+
interface RouteHeadConfig {
|
|
252
|
+
/** Page title */
|
|
253
|
+
title?: string;
|
|
254
|
+
/** Title template (e.g., '%s | My App') */
|
|
255
|
+
titleTemplate?: string | ((title: string) => string);
|
|
256
|
+
/** Meta tags */
|
|
257
|
+
meta?: Array<{
|
|
258
|
+
name?: string;
|
|
259
|
+
property?: string;
|
|
260
|
+
content?: string;
|
|
261
|
+
charset?: string;
|
|
262
|
+
"http-equiv"?: string;
|
|
263
|
+
[key: string]: string | undefined;
|
|
264
|
+
}>;
|
|
265
|
+
/** Link tags */
|
|
266
|
+
link?: Array<{
|
|
267
|
+
rel?: string;
|
|
268
|
+
href?: string;
|
|
269
|
+
type?: string;
|
|
270
|
+
as?: string;
|
|
271
|
+
crossorigin?: string;
|
|
272
|
+
media?: string;
|
|
273
|
+
sizes?: string;
|
|
274
|
+
hreflang?: string;
|
|
275
|
+
title?: string;
|
|
276
|
+
[key: string]: string | undefined;
|
|
277
|
+
}>;
|
|
278
|
+
/** Script tags */
|
|
279
|
+
script?: Array<{
|
|
280
|
+
src?: string;
|
|
281
|
+
async?: boolean;
|
|
282
|
+
defer?: boolean;
|
|
283
|
+
type?: string;
|
|
284
|
+
innerHTML?: string;
|
|
285
|
+
[key: string]: string | boolean | undefined;
|
|
286
|
+
}>;
|
|
287
|
+
/** Style tags */
|
|
288
|
+
style?: Array<{
|
|
289
|
+
innerHTML?: string;
|
|
290
|
+
media?: string;
|
|
291
|
+
type?: string;
|
|
292
|
+
[key: string]: string | undefined;
|
|
293
|
+
}>;
|
|
294
|
+
/** HTML attributes */
|
|
295
|
+
htmlAttrs?: {
|
|
296
|
+
lang?: string;
|
|
297
|
+
dir?: "ltr" | "rtl" | "auto";
|
|
298
|
+
class?: string;
|
|
299
|
+
[key: string]: string | undefined;
|
|
300
|
+
};
|
|
301
|
+
/** Body attributes */
|
|
302
|
+
bodyAttrs?: {
|
|
303
|
+
class?: string;
|
|
304
|
+
[key: string]: string | undefined;
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Route head function signature
|
|
309
|
+
*/
|
|
310
|
+
type RouteHeadFn<TParams = Record<string, string>, TLoaderData = unknown> = (context: RouteHeadContext<TParams, TLoaderData>) => RouteHeadConfig;
|
|
311
|
+
/**
|
|
312
|
+
* File route options
|
|
313
|
+
*/
|
|
314
|
+
interface FileRouteOptions<TMeta = unknown, TParams = Record<string, string>, TSearch = Record<string, unknown>, TLoaderData = unknown> {
|
|
315
|
+
/** Route meta */
|
|
316
|
+
meta?: TMeta;
|
|
317
|
+
/** Loader function - runs before navigation completes */
|
|
318
|
+
loader?: LoaderFn<TParams, TSearch, TLoaderData>;
|
|
319
|
+
/** Search params validation schema (Zod compatible) */
|
|
320
|
+
validateSearch?: SearchSchema<TSearch>;
|
|
321
|
+
/** Before load hook */
|
|
322
|
+
beforeLoad?: (ctx: BeforeLoadContext) => Promise<void> | void;
|
|
323
|
+
/**
|
|
324
|
+
* Route-level head configuration
|
|
325
|
+
*
|
|
326
|
+
* @example Static head
|
|
327
|
+
* ```ts
|
|
328
|
+
* head: {
|
|
329
|
+
* title: 'About Us',
|
|
330
|
+
* meta: [{ name: 'description', content: 'Learn about our company' }]
|
|
331
|
+
* }
|
|
332
|
+
* ```
|
|
333
|
+
*
|
|
334
|
+
* @example Dynamic head from loader
|
|
335
|
+
* ```ts
|
|
336
|
+
* head: ({ loaderData }) => ({
|
|
337
|
+
* title: loaderData.post.title,
|
|
338
|
+
* meta: [{ property: 'og:title', content: loaderData.post.title }]
|
|
339
|
+
* })
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
head?: RouteHeadFn<TParams, TLoaderData> | RouteHeadConfig;
|
|
343
|
+
/**
|
|
344
|
+
* Page transition configuration
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* ```ts
|
|
348
|
+
* transition: { name: 'slide', mode: 'out-in' }
|
|
349
|
+
* // or disable transition
|
|
350
|
+
* transition: false
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
transition?: boolean | TransitionProps;
|
|
354
|
+
/**
|
|
355
|
+
* View Transition API (experimental)
|
|
356
|
+
* Uses native browser document.startViewTransition() API
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```ts
|
|
360
|
+
* viewTransition: true // respect user's prefers-reduced-motion
|
|
361
|
+
* viewTransition: 'always' // always use view transitions
|
|
362
|
+
* ```
|
|
363
|
+
*/
|
|
364
|
+
viewTransition?: boolean | "always";
|
|
365
|
+
/**
|
|
366
|
+
* KeepAlive configuration for route component
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
* ```ts
|
|
370
|
+
* keepalive: true
|
|
371
|
+
* keepalive: { max: 10 }
|
|
372
|
+
* ```
|
|
373
|
+
*/
|
|
374
|
+
keepalive?: boolean | KeepAliveProps;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Before load context
|
|
378
|
+
*/
|
|
379
|
+
interface BeforeLoadContext {
|
|
380
|
+
/** Current route */
|
|
381
|
+
route: RouteLocationNormalizedLoaded$1;
|
|
382
|
+
/** Router instance */
|
|
383
|
+
router: Router$1;
|
|
384
|
+
/** Abort navigation */
|
|
385
|
+
abort: () => void;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Route definition returned by createFileRoute
|
|
389
|
+
*/
|
|
390
|
+
interface RouteDefinition<TPath extends string = string, TMeta = unknown, TParams = Record<string, string>, TSearch = Record<string, unknown>, TLoaderData = unknown> {
|
|
391
|
+
path: TPath;
|
|
392
|
+
meta?: TMeta;
|
|
393
|
+
loader?: LoaderFn<TParams, TSearch, TLoaderData>;
|
|
394
|
+
validateSearch?: SearchSchema<TSearch>;
|
|
395
|
+
beforeLoad?: (ctx: BeforeLoadContext) => Promise<void> | void;
|
|
396
|
+
head?: RouteHeadFn<TParams, TLoaderData> | RouteHeadConfig;
|
|
397
|
+
transition?: boolean | TransitionProps;
|
|
398
|
+
viewTransition?: boolean | "always";
|
|
399
|
+
keepalive?: boolean | KeepAliveProps;
|
|
400
|
+
}
|
|
401
|
+
declare module "vue-router" {
|
|
402
|
+
interface RouteMeta {
|
|
403
|
+
/** Kimesh route definition with loader */
|
|
404
|
+
__kimesh?: RouteDefinition;
|
|
405
|
+
/** Error from loader execution */
|
|
406
|
+
__kimeshError?: unknown;
|
|
407
|
+
/** Source layer name for layer-aware features */
|
|
408
|
+
__kimeshLayer?: string;
|
|
409
|
+
}
|
|
410
|
+
} //# sourceMappingURL=types.d.ts.map
|
|
411
|
+
//#endregion
|
|
412
|
+
//#region src/create-app.d.ts
|
|
413
|
+
declare const KIMESH_APP_CONTEXT_KEY: InjectionKey<KimeshAppContext>;
|
|
414
|
+
interface CreateKimeshAppOptionsExtended extends CreateKimeshAppOptions {
|
|
415
|
+
plugins?: KimeshRuntimePlugin[];
|
|
416
|
+
runtimeConfig?: RuntimeConfigPublic;
|
|
417
|
+
/** Per-layer runtime configs (for layer-aware features like $fetch) */
|
|
418
|
+
layersConfig?: Record<string, Record<string, unknown>>;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Create a Kimesh application with router, query client, and runtime plugins
|
|
422
|
+
*/
|
|
423
|
+
declare function createKimeshApp(options: CreateKimeshAppOptionsExtended): Promise<KimeshApp>;
|
|
424
|
+
//#endregion
|
|
425
|
+
//#region src/create-file-route.d.ts
|
|
426
|
+
/**
|
|
427
|
+
* Create a file-based route definition
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```ts
|
|
431
|
+
* // In routes/about.vue
|
|
432
|
+
* export const Route = createFileRoute('/about')({
|
|
433
|
+
* meta: { title: 'About Us' },
|
|
434
|
+
* loader: async () => {
|
|
435
|
+
* return { data: await fetchAboutData() }
|
|
436
|
+
* },
|
|
437
|
+
* head: {
|
|
438
|
+
* title: 'About Us',
|
|
439
|
+
* meta: [{ name: 'description', content: 'Learn about us' }]
|
|
440
|
+
* }
|
|
441
|
+
* })
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
444
|
+
declare function createFileRoute<TPath extends string>(path: TPath): <TMeta = unknown>(options?: FileRouteOptions<TMeta>) => RouteDefinition<TPath, TMeta>;
|
|
445
|
+
/**
|
|
446
|
+
* Define route for use in Vue SFC
|
|
447
|
+
* Alternative syntax for createFileRoute
|
|
448
|
+
*/
|
|
449
|
+
declare function defineRoute<TMeta = unknown>(options: FileRouteOptions<TMeta>): FileRouteOptions<TMeta>;
|
|
450
|
+
//#endregion
|
|
451
|
+
//#region src/context.d.ts
|
|
452
|
+
/**
|
|
453
|
+
* Define app context with type inference
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* ```ts
|
|
457
|
+
* // src/app.context.ts
|
|
458
|
+
* import { defineContext } from '@kimesh/router-runtime'
|
|
459
|
+
*
|
|
460
|
+
* export default defineContext(() => ({
|
|
461
|
+
* auth: useAuthStore(),
|
|
462
|
+
* i18n: createI18n(),
|
|
463
|
+
* }))
|
|
464
|
+
* ```
|
|
465
|
+
*/
|
|
466
|
+
declare function defineContext<T extends KimeshContext>(factory: () => T): () => T;
|
|
467
|
+
/**
|
|
468
|
+
* Use Kimesh context in components
|
|
469
|
+
*
|
|
470
|
+
* @example
|
|
471
|
+
* ```vue
|
|
472
|
+
* <script setup>
|
|
473
|
+
* const ctx = useKimeshContext()
|
|
474
|
+
* ctx.auth.logout()
|
|
475
|
+
* </script>
|
|
476
|
+
* ```
|
|
477
|
+
*/
|
|
478
|
+
declare function useKimeshContext(): FullContext;
|
|
479
|
+
//#endregion
|
|
480
|
+
//#region src/runtime-plugin.d.ts
|
|
481
|
+
declare const KIMESH_PLUGIN_INDICATOR: "__kimesh_plugin";
|
|
482
|
+
/**
|
|
483
|
+
* Define a Kimesh runtime plugin
|
|
484
|
+
*
|
|
485
|
+
* @example Function-style plugin
|
|
486
|
+
* ```ts
|
|
487
|
+
* export default defineKimeshRuntimePlugin((app) => {
|
|
488
|
+
* const analytics = new AnalyticsService()
|
|
489
|
+
* app.router.afterEach((to) => analytics.trackPageView(to.path))
|
|
490
|
+
* return { provide: { analytics } }
|
|
491
|
+
* })
|
|
492
|
+
* ```
|
|
493
|
+
*
|
|
494
|
+
* @example Object-style plugin with hooks
|
|
495
|
+
* ```ts
|
|
496
|
+
* export default defineKimeshRuntimePlugin({
|
|
497
|
+
* name: 'my-plugin',
|
|
498
|
+
* enforce: 'pre',
|
|
499
|
+
* hooks: {
|
|
500
|
+
* 'app:mounted': () => console.log('App mounted!')
|
|
501
|
+
* },
|
|
502
|
+
* setup(app) {
|
|
503
|
+
* return { provide: { myService: new MyService() } }
|
|
504
|
+
* }
|
|
505
|
+
* })
|
|
506
|
+
* ```
|
|
507
|
+
*/
|
|
508
|
+
declare function defineKimeshRuntimePlugin<Injections extends Record<string, unknown> = Record<string, unknown>>(plugin: KimeshRuntimePlugin<Injections> | KimeshRuntimePluginDefinition<Injections>): KimeshRuntimePlugin<Injections>;
|
|
509
|
+
/**
|
|
510
|
+
* Check if a value is a Kimesh runtime plugin
|
|
511
|
+
*/
|
|
512
|
+
declare function isKimeshRuntimePlugin(value: unknown): value is KimeshRuntimePlugin;
|
|
513
|
+
/**
|
|
514
|
+
* Get plugin metadata
|
|
515
|
+
*/
|
|
516
|
+
declare function getPluginMeta(plugin: KimeshRuntimePlugin): KimeshRuntimePluginMeta;
|
|
517
|
+
/**
|
|
518
|
+
* Get plugin name
|
|
519
|
+
*/
|
|
520
|
+
declare function getPluginName(plugin: KimeshRuntimePlugin): string;
|
|
521
|
+
/**
|
|
522
|
+
* Get plugin hooks
|
|
523
|
+
*/
|
|
524
|
+
declare function getPluginHooks(plugin: KimeshRuntimePlugin): Partial<KimeshRuntimeHooks> | undefined;
|
|
525
|
+
//#endregion
|
|
526
|
+
//#region src/plugin-executor.d.ts
|
|
527
|
+
/**
|
|
528
|
+
* Apply a single plugin to the app context
|
|
529
|
+
*/
|
|
530
|
+
declare function applyPlugin(app: KimeshAppContext, plugin: KimeshRuntimePlugin): Promise<void>;
|
|
531
|
+
/**
|
|
532
|
+
* Apply all plugins to the app context with dependency resolution
|
|
533
|
+
*/
|
|
534
|
+
declare function applyPlugins(app: KimeshAppContext, plugins: KimeshRuntimePlugin[]): Promise<void>;
|
|
535
|
+
/**
|
|
536
|
+
* Apply plugins with parallel support.
|
|
537
|
+
* Plugins with parallel: true run concurrently within their group.
|
|
538
|
+
*/
|
|
539
|
+
declare function applyPluginsWithParallel(app: KimeshAppContext, plugins: KimeshRuntimePlugin[]): Promise<void>;
|
|
540
|
+
//#endregion
|
|
541
|
+
//#region src/plugins/core.d.ts
|
|
542
|
+
/**
|
|
543
|
+
* @kimesh/router-runtime - Core Plugins
|
|
544
|
+
*
|
|
545
|
+
* Built-in runtime plugins for Kimesh.
|
|
546
|
+
*/
|
|
547
|
+
/**
|
|
548
|
+
* Router plugin that wires Vue Router guards to Kimesh hook system
|
|
549
|
+
*
|
|
550
|
+
* This plugin runs with `enforce: 'pre'` to ensure router hooks
|
|
551
|
+
* are available to all other plugins.
|
|
552
|
+
*/
|
|
553
|
+
declare const routerPlugin: KimeshRuntimePlugin<Record<string, unknown>>;
|
|
554
|
+
interface QueryPluginOptions {
|
|
555
|
+
/** Enable route-based prefetching */
|
|
556
|
+
prefetching?: boolean;
|
|
557
|
+
/** Paths to exclude from prefetching */
|
|
558
|
+
excludePrefetch?: (string | RegExp)[];
|
|
559
|
+
[key: string]: unknown;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Query plugin that sets up prefetching on navigation
|
|
563
|
+
*
|
|
564
|
+
* Note: QueryClient is already initialized in createKimeshApp,
|
|
565
|
+
* this plugin adds navigation-based prefetching.
|
|
566
|
+
*/
|
|
567
|
+
declare const queryPlugin: KimeshRuntimePlugin<QueryPluginOptions>;
|
|
568
|
+
/**
|
|
569
|
+
* Get the default core plugins for a Kimesh app
|
|
570
|
+
*/
|
|
571
|
+
declare function getCorePlugins(): KimeshRuntimePlugin<Record<string, unknown>>[];
|
|
572
|
+
//#endregion
|
|
573
|
+
//#region src/components/KmOutlet.d.ts
|
|
574
|
+
/**
|
|
575
|
+
* KmOutlet - Router view wrapper component
|
|
576
|
+
* Renders the matched route component with optional transitions and keepalive
|
|
577
|
+
*
|
|
578
|
+
* Transition options for async pages (useSuspenseQuery):
|
|
579
|
+
*
|
|
580
|
+
* 1. viewTransition: true (Recommended)
|
|
581
|
+
* - Uses View Transitions API (Chrome 111+, Edge 111+, Opera 97+)
|
|
582
|
+
* - Works perfectly with async pages
|
|
583
|
+
* - Falls back to instant transition on unsupported browsers
|
|
584
|
+
*
|
|
585
|
+
* 2. transition: { name: 'fade' } (without mode: 'out-in')
|
|
586
|
+
* - Uses Vue Transition with default mode (cross-fade)
|
|
587
|
+
* - Both pages exist during transition (old fades out, new fades in)
|
|
588
|
+
* - Requires CSS: .page-leave-active { position: absolute }
|
|
589
|
+
*
|
|
590
|
+
* 3. transition: { name: 'fade', mode: 'out-in' }
|
|
591
|
+
* - ⚠️ NOT recommended for async pages - may cause blank screen
|
|
592
|
+
*/
|
|
593
|
+
declare const KmOutlet: vue13.DefineComponent<vue13.ExtractPropTypes<{
|
|
594
|
+
name: {
|
|
595
|
+
type: StringConstructor;
|
|
596
|
+
default: string;
|
|
597
|
+
};
|
|
598
|
+
/**
|
|
599
|
+
* Page transition configuration (Vue Transition)
|
|
600
|
+
* ⚠️ Avoid mode: 'out-in' with async pages
|
|
601
|
+
*/
|
|
602
|
+
transition: {
|
|
603
|
+
type: any;
|
|
604
|
+
default: undefined;
|
|
605
|
+
};
|
|
606
|
+
/**
|
|
607
|
+
* Enable View Transitions API (recommended for async pages)
|
|
608
|
+
* Works in Chrome 111+, Edge 111+, Opera 97+
|
|
609
|
+
* Falls back to instant transition on unsupported browsers
|
|
610
|
+
*/
|
|
611
|
+
viewTransition: {
|
|
612
|
+
type: BooleanConstructor;
|
|
613
|
+
default: boolean;
|
|
614
|
+
};
|
|
615
|
+
/**
|
|
616
|
+
* KeepAlive configuration
|
|
617
|
+
*/
|
|
618
|
+
keepalive: {
|
|
619
|
+
type: any;
|
|
620
|
+
default: undefined;
|
|
621
|
+
};
|
|
622
|
+
/**
|
|
623
|
+
* Custom page key function for route identification
|
|
624
|
+
*/
|
|
625
|
+
pageKey: {
|
|
626
|
+
type: any;
|
|
627
|
+
default: null;
|
|
628
|
+
};
|
|
629
|
+
}>, () => VNode, {}, {}, {}, vue13.ComponentOptionsMixin, vue13.ComponentOptionsMixin, {}, string, vue13.PublicProps, Readonly<vue13.ExtractPropTypes<{
|
|
630
|
+
name: {
|
|
631
|
+
type: StringConstructor;
|
|
632
|
+
default: string;
|
|
633
|
+
};
|
|
634
|
+
/**
|
|
635
|
+
* Page transition configuration (Vue Transition)
|
|
636
|
+
* ⚠️ Avoid mode: 'out-in' with async pages
|
|
637
|
+
*/
|
|
638
|
+
transition: {
|
|
639
|
+
type: any;
|
|
640
|
+
default: undefined;
|
|
641
|
+
};
|
|
642
|
+
/**
|
|
643
|
+
* Enable View Transitions API (recommended for async pages)
|
|
644
|
+
* Works in Chrome 111+, Edge 111+, Opera 97+
|
|
645
|
+
* Falls back to instant transition on unsupported browsers
|
|
646
|
+
*/
|
|
647
|
+
viewTransition: {
|
|
648
|
+
type: BooleanConstructor;
|
|
649
|
+
default: boolean;
|
|
650
|
+
};
|
|
651
|
+
/**
|
|
652
|
+
* KeepAlive configuration
|
|
653
|
+
*/
|
|
654
|
+
keepalive: {
|
|
655
|
+
type: any;
|
|
656
|
+
default: undefined;
|
|
657
|
+
};
|
|
658
|
+
/**
|
|
659
|
+
* Custom page key function for route identification
|
|
660
|
+
*/
|
|
661
|
+
pageKey: {
|
|
662
|
+
type: any;
|
|
663
|
+
default: null;
|
|
664
|
+
};
|
|
665
|
+
}>> & Readonly<{}>, {
|
|
666
|
+
name: string;
|
|
667
|
+
transition: any;
|
|
668
|
+
viewTransition: boolean;
|
|
669
|
+
keepalive: any;
|
|
670
|
+
pageKey: any;
|
|
671
|
+
}, {}, {}, {}, string, vue13.ComponentProvideOptions, true, {}, any>;
|
|
672
|
+
//#endregion
|
|
673
|
+
//#region src/components/KmLink.d.ts
|
|
674
|
+
/**
|
|
675
|
+
* Type-safe link props - requires params if route has them
|
|
676
|
+
* Allows both named routes (with autocomplete) and raw string paths
|
|
677
|
+
*/
|
|
678
|
+
type KmLinkProps<T extends string = RouteNames> = T extends RouteNames ? HasParams<T> extends true ? {
|
|
679
|
+
to: T;
|
|
680
|
+
params: RouteParamsRaw<T>;
|
|
681
|
+
replace?: boolean;
|
|
682
|
+
} : HasParams<T> extends false ? {
|
|
683
|
+
to: T;
|
|
684
|
+
params?: undefined;
|
|
685
|
+
replace?: boolean;
|
|
686
|
+
} : {
|
|
687
|
+
to: T;
|
|
688
|
+
params?: Record<string, string | number>;
|
|
689
|
+
replace?: boolean;
|
|
690
|
+
} : {
|
|
691
|
+
to: T;
|
|
692
|
+
params?: Record<string, string | number>;
|
|
693
|
+
replace?: boolean;
|
|
694
|
+
};
|
|
695
|
+
/**
|
|
696
|
+
* KmLink - Type-safe router link component
|
|
697
|
+
*
|
|
698
|
+
* @example
|
|
699
|
+
* ```vue
|
|
700
|
+
* <!-- Static route -->
|
|
701
|
+
* <KmLink to="/posts">Posts</KmLink>
|
|
702
|
+
*
|
|
703
|
+
* <!-- Dynamic route with params -->
|
|
704
|
+
* <KmLink to="/posts/:postId" :params="{ postId: '123' }">
|
|
705
|
+
* Post 123
|
|
706
|
+
* </KmLink>
|
|
707
|
+
* ```
|
|
708
|
+
*/
|
|
709
|
+
declare const KmLink: vue13.DefineComponent<vue13.ExtractPropTypes<{
|
|
710
|
+
to: {
|
|
711
|
+
type: PropType<RouteLocationRaw>;
|
|
712
|
+
required: true;
|
|
713
|
+
};
|
|
714
|
+
params: {
|
|
715
|
+
type: PropType<Record<string, string | number>>;
|
|
716
|
+
default: undefined;
|
|
717
|
+
};
|
|
718
|
+
replace: {
|
|
719
|
+
type: BooleanConstructor;
|
|
720
|
+
default: boolean;
|
|
721
|
+
};
|
|
722
|
+
activeClass: {
|
|
723
|
+
type: StringConstructor;
|
|
724
|
+
default: string;
|
|
725
|
+
};
|
|
726
|
+
exactActiveClass: {
|
|
727
|
+
type: StringConstructor;
|
|
728
|
+
default: string;
|
|
729
|
+
};
|
|
730
|
+
prefetch: {
|
|
731
|
+
type: BooleanConstructor;
|
|
732
|
+
default: boolean;
|
|
733
|
+
};
|
|
734
|
+
tag: {
|
|
735
|
+
type: StringConstructor;
|
|
736
|
+
default: string;
|
|
737
|
+
};
|
|
738
|
+
}>, () => vue13.VNode<vue13.RendererNode, vue13.RendererElement, {
|
|
739
|
+
[key: string]: any;
|
|
740
|
+
}>, {}, {}, {}, vue13.ComponentOptionsMixin, vue13.ComponentOptionsMixin, {}, string, vue13.PublicProps, Readonly<vue13.ExtractPropTypes<{
|
|
741
|
+
to: {
|
|
742
|
+
type: PropType<RouteLocationRaw>;
|
|
743
|
+
required: true;
|
|
744
|
+
};
|
|
745
|
+
params: {
|
|
746
|
+
type: PropType<Record<string, string | number>>;
|
|
747
|
+
default: undefined;
|
|
748
|
+
};
|
|
749
|
+
replace: {
|
|
750
|
+
type: BooleanConstructor;
|
|
751
|
+
default: boolean;
|
|
752
|
+
};
|
|
753
|
+
activeClass: {
|
|
754
|
+
type: StringConstructor;
|
|
755
|
+
default: string;
|
|
756
|
+
};
|
|
757
|
+
exactActiveClass: {
|
|
758
|
+
type: StringConstructor;
|
|
759
|
+
default: string;
|
|
760
|
+
};
|
|
761
|
+
prefetch: {
|
|
762
|
+
type: BooleanConstructor;
|
|
763
|
+
default: boolean;
|
|
764
|
+
};
|
|
765
|
+
tag: {
|
|
766
|
+
type: StringConstructor;
|
|
767
|
+
default: string;
|
|
768
|
+
};
|
|
769
|
+
}>> & Readonly<{}>, {
|
|
770
|
+
params: Record<string, string | number>;
|
|
771
|
+
replace: boolean;
|
|
772
|
+
activeClass: string;
|
|
773
|
+
exactActiveClass: string;
|
|
774
|
+
prefetch: boolean;
|
|
775
|
+
tag: string;
|
|
776
|
+
}, {}, {}, {}, string, vue13.ComponentProvideOptions, true, {}, any>;
|
|
777
|
+
//#endregion
|
|
778
|
+
//#region src/components/KmDeferred.d.ts
|
|
779
|
+
/**
|
|
780
|
+
* KmDeferred - Suspense wrapper with error handling
|
|
781
|
+
*
|
|
782
|
+
* Wraps Vue's <Suspense> with error boundary functionality.
|
|
783
|
+
* Use with useSuspenseQuery for progressive data loading.
|
|
784
|
+
*
|
|
785
|
+
* @example
|
|
786
|
+
* ```vue
|
|
787
|
+
* <KmDeferred :timeout="200">
|
|
788
|
+
* <AsyncDataComponent />
|
|
789
|
+
* <template #fallback>
|
|
790
|
+
* <Skeleton />
|
|
791
|
+
* </template>
|
|
792
|
+
* <template #error="{ error, retry }">
|
|
793
|
+
* <ErrorCard :error="error" @retry="retry" />
|
|
794
|
+
* </template>
|
|
795
|
+
* </KmDeferred>
|
|
796
|
+
* ```
|
|
797
|
+
*/
|
|
798
|
+
declare const KmDeferred: vue13.DefineComponent<vue13.ExtractPropTypes<{
|
|
799
|
+
/**
|
|
800
|
+
* Delay in ms before showing fallback (default: 0)
|
|
801
|
+
* Helps avoid flashing loading states for fast loads
|
|
802
|
+
*/
|
|
803
|
+
timeout: {
|
|
804
|
+
type: PropType<number>;
|
|
805
|
+
default: number;
|
|
806
|
+
};
|
|
807
|
+
}>, () => VNode, {}, {}, {}, vue13.ComponentOptionsMixin, vue13.ComponentOptionsMixin, {}, string, vue13.PublicProps, Readonly<vue13.ExtractPropTypes<{
|
|
808
|
+
/**
|
|
809
|
+
* Delay in ms before showing fallback (default: 0)
|
|
810
|
+
* Helps avoid flashing loading states for fast loads
|
|
811
|
+
*/
|
|
812
|
+
timeout: {
|
|
813
|
+
type: PropType<number>;
|
|
814
|
+
default: number;
|
|
815
|
+
};
|
|
816
|
+
}>> & Readonly<{}>, {
|
|
817
|
+
timeout: number;
|
|
818
|
+
}, {}, {}, {}, string, vue13.ComponentProvideOptions, true, {}, any>;
|
|
819
|
+
//#endregion
|
|
820
|
+
//#region src/guards/loader-guard.d.ts
|
|
821
|
+
interface LoaderGuardOptions {
|
|
822
|
+
onError?: (error: Error, to: RouteLocationNormalized$1) => void;
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Create the loader navigation guard
|
|
826
|
+
*/
|
|
827
|
+
declare function createLoaderGuard(context: FullContext, options?: LoaderGuardOptions): (to: RouteLocationNormalized$1, from: RouteLocationNormalized$1, abortController: AbortController) => Promise<void>;
|
|
828
|
+
/**
|
|
829
|
+
* Install loader guard on router
|
|
830
|
+
*/
|
|
831
|
+
declare function installLoaderGuard(router: Router$1, context: FullContext, options?: {
|
|
832
|
+
onError?: (error: Error, to: RouteLocationNormalized$1) => void;
|
|
833
|
+
}): () => void;
|
|
834
|
+
//#endregion
|
|
835
|
+
//#region src/composables/use-search.d.ts
|
|
836
|
+
interface UseSearchReturn<T> {
|
|
837
|
+
search: ComputedRef<T>;
|
|
838
|
+
setSearch: <K extends keyof T>(key: K, value: T[K]) => void;
|
|
839
|
+
setAllSearch: (params: Partial<T>) => void;
|
|
840
|
+
resetSearch: () => void;
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Access and update validated search params
|
|
844
|
+
*
|
|
845
|
+
* @example
|
|
846
|
+
* ```vue
|
|
847
|
+
* <script setup>
|
|
848
|
+
* import { useSearch } from '@kimesh/router-runtime'
|
|
849
|
+
* import { z } from 'zod'
|
|
850
|
+
*
|
|
851
|
+
* const searchSchema = z.object({
|
|
852
|
+
* page: z.coerce.number().default(1),
|
|
853
|
+
* sort: z.enum(['asc', 'desc']).default('desc')
|
|
854
|
+
* })
|
|
855
|
+
*
|
|
856
|
+
* const { search, setSearch } = useSearch(searchSchema)
|
|
857
|
+
* </script>
|
|
858
|
+
* ```
|
|
859
|
+
*/
|
|
860
|
+
declare function useSearch<T>(schema: SearchSchema<T>): UseSearchReturn<T>;
|
|
861
|
+
//#endregion
|
|
862
|
+
//#region src/composables/use-params.d.ts
|
|
863
|
+
/**
|
|
864
|
+
* Get typed route params (non-reactive snapshot)
|
|
865
|
+
*
|
|
866
|
+
* @example
|
|
867
|
+
* ```ts
|
|
868
|
+
* // In /posts/:postId page
|
|
869
|
+
* const params = useParams<'/posts/:postId'>()
|
|
870
|
+
* // params is typed as { postId: string }
|
|
871
|
+
* console.log(params.postId)
|
|
872
|
+
* ```
|
|
873
|
+
*/
|
|
874
|
+
declare function useParams<T extends string = RouteNames>(): RouteParams<T>;
|
|
875
|
+
/**
|
|
876
|
+
* Get reactive typed route params
|
|
877
|
+
*
|
|
878
|
+
* @example
|
|
879
|
+
* ```ts
|
|
880
|
+
* // In /posts/:postId page
|
|
881
|
+
* const params = useReactiveParams<'/posts/:postId'>()
|
|
882
|
+
* // params.value is typed as { postId: string }
|
|
883
|
+
* watchEffect(() => {
|
|
884
|
+
* console.log(params.value.postId)
|
|
885
|
+
* })
|
|
886
|
+
* ```
|
|
887
|
+
*/
|
|
888
|
+
declare function useReactiveParams<T extends string = RouteNames>(): ComputedRef<RouteParams<T>>;
|
|
889
|
+
//#endregion
|
|
890
|
+
//#region src/composables/use-navigate.d.ts
|
|
891
|
+
/**
|
|
892
|
+
* Navigation options - requires params if route has them
|
|
893
|
+
* Allows both named routes (with autocomplete) and raw string paths
|
|
894
|
+
*/
|
|
895
|
+
type NavigateOptions<T extends string = RouteNames> = T extends RouteNames ? (HasParams<T> extends true ? {
|
|
896
|
+
to: T;
|
|
897
|
+
params: RouteParamsRaw<T>;
|
|
898
|
+
replace?: boolean;
|
|
899
|
+
} : HasParams<T> extends false ? {
|
|
900
|
+
to: T;
|
|
901
|
+
params?: undefined;
|
|
902
|
+
replace?: boolean;
|
|
903
|
+
} : {
|
|
904
|
+
to: T;
|
|
905
|
+
params?: Record<string, string | number>;
|
|
906
|
+
replace?: boolean;
|
|
907
|
+
}) : {
|
|
908
|
+
to: T;
|
|
909
|
+
params?: Record<string, string | number>;
|
|
910
|
+
replace?: boolean;
|
|
911
|
+
};
|
|
912
|
+
/**
|
|
913
|
+
* Type-safe navigation composable
|
|
914
|
+
*
|
|
915
|
+
* @example
|
|
916
|
+
* ```ts
|
|
917
|
+
* const { navigate } = useNavigate()
|
|
918
|
+
*
|
|
919
|
+
* // Navigate to static route
|
|
920
|
+
* navigate({ to: '/posts' })
|
|
921
|
+
*
|
|
922
|
+
* // Navigate to dynamic route with params
|
|
923
|
+
* navigate({ to: '/posts/:postId', params: { postId: '123' } })
|
|
924
|
+
*
|
|
925
|
+
* // Replace instead of push
|
|
926
|
+
* navigate({ to: '/posts', replace: true })
|
|
927
|
+
* ```
|
|
928
|
+
*/
|
|
929
|
+
declare function useNavigate(): {
|
|
930
|
+
navigate: <T extends RouteLocationRaw = string>(options: NavigateOptions<T>) => Promise<void | vue_router0.NavigationFailure | undefined>;
|
|
931
|
+
back: () => void;
|
|
932
|
+
forward: () => void;
|
|
933
|
+
go: (delta: number) => void;
|
|
934
|
+
router: vue_router0.Router;
|
|
935
|
+
};
|
|
936
|
+
//#endregion
|
|
937
|
+
//#region src/composables/use-runtime-config.d.ts
|
|
938
|
+
/**
|
|
939
|
+
* @kimesh/router-runtime - useRuntimeConfig composable
|
|
940
|
+
*
|
|
941
|
+
* Provides type-safe access to runtime configuration.
|
|
942
|
+
* Phase 1: Client-side only, returns build-time injected config.
|
|
943
|
+
*/
|
|
944
|
+
/**
|
|
945
|
+
* Runtime configuration type.
|
|
946
|
+
* Users can extend this interface via declaration merging for type-safe config access.
|
|
947
|
+
*
|
|
948
|
+
* @example
|
|
949
|
+
* ```ts
|
|
950
|
+
* // src/types/runtime-config.d.ts
|
|
951
|
+
* declare module '@kimesh/router-runtime' {
|
|
952
|
+
* interface RuntimeConfig {
|
|
953
|
+
* apiBase: string;
|
|
954
|
+
* debug: boolean;
|
|
955
|
+
* features: {
|
|
956
|
+
* darkMode: boolean;
|
|
957
|
+
* };
|
|
958
|
+
* }
|
|
959
|
+
* }
|
|
960
|
+
* ```
|
|
961
|
+
*/
|
|
962
|
+
interface RuntimeConfig {
|
|
963
|
+
[key: string]: unknown;
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Access runtime configuration.
|
|
967
|
+
*
|
|
968
|
+
* Returns the runtime config that was injected at build time via Vite's `define`.
|
|
969
|
+
* Values can be overridden using `KIMESH_*` environment variables during build.
|
|
970
|
+
*
|
|
971
|
+
* @returns Frozen runtime config object
|
|
972
|
+
*
|
|
973
|
+
* @example
|
|
974
|
+
* ```vue
|
|
975
|
+
* <script setup>
|
|
976
|
+
* const config = useRuntimeConfig()
|
|
977
|
+
* console.log(config.apiBase)
|
|
978
|
+
* console.log(config.debug)
|
|
979
|
+
* </script>
|
|
980
|
+
* ```
|
|
981
|
+
*
|
|
982
|
+
* @example
|
|
983
|
+
* ```ts
|
|
984
|
+
* // In a composable
|
|
985
|
+
* export function useApi() {
|
|
986
|
+
* const config = useRuntimeConfig()
|
|
987
|
+
*
|
|
988
|
+
* async function fetch<T>(endpoint: string): Promise<T> {
|
|
989
|
+
* const url = `${config.apiBase}${endpoint}`
|
|
990
|
+
* const response = await globalThis.fetch(url)
|
|
991
|
+
* return response.json()
|
|
992
|
+
* }
|
|
993
|
+
*
|
|
994
|
+
* return { fetch }
|
|
995
|
+
* }
|
|
996
|
+
* ```
|
|
997
|
+
*/
|
|
998
|
+
declare function useRuntimeConfig<T extends RuntimeConfig = RuntimeConfig>(): T;
|
|
999
|
+
//#endregion
|
|
1000
|
+
//#region src/composables/use-kimesh-app.d.ts
|
|
1001
|
+
/**
|
|
1002
|
+
* Get the Kimesh app context
|
|
1003
|
+
*
|
|
1004
|
+
* @example
|
|
1005
|
+
* ```ts
|
|
1006
|
+
* const { router, queryClient, $config } = useKimeshApp()
|
|
1007
|
+
* console.log($config.apiUrl)
|
|
1008
|
+
* ```
|
|
1009
|
+
*
|
|
1010
|
+
* @throws Error if called outside a Kimesh app
|
|
1011
|
+
*/
|
|
1012
|
+
declare function useKimeshApp(): KimeshAppContext;
|
|
1013
|
+
/**
|
|
1014
|
+
* Try to get the Kimesh app context without throwing
|
|
1015
|
+
*/
|
|
1016
|
+
declare function tryUseKimeshApp(): KimeshAppContext | undefined;
|
|
1017
|
+
//#endregion
|
|
1018
|
+
//#region src/composables/useState.d.ts
|
|
1019
|
+
declare const STATE_KEY_PREFIX = "$s_";
|
|
1020
|
+
/**
|
|
1021
|
+
* Get all state keys (without prefix).
|
|
1022
|
+
*/
|
|
1023
|
+
declare function getKmStateKeys(): string[];
|
|
1024
|
+
/**
|
|
1025
|
+
* Check if a state exists.
|
|
1026
|
+
*/
|
|
1027
|
+
declare function hasKmState(key: string): boolean;
|
|
1028
|
+
/**
|
|
1029
|
+
* Clear Kimesh state by key(s) or predicate.
|
|
1030
|
+
* Pass undefined to clear all state, a string for single key,
|
|
1031
|
+
* an array for multiple keys, or a predicate function.
|
|
1032
|
+
*/
|
|
1033
|
+
declare function clearKmState(keys?: string | string[] | ((key: string) => boolean)): void;
|
|
1034
|
+
/**
|
|
1035
|
+
* Get or create reactive state by key.
|
|
1036
|
+
*
|
|
1037
|
+
* @throws TypeError if key is not a non-empty string or init is not a function
|
|
1038
|
+
* @throws Error if _state is not initialized
|
|
1039
|
+
*/
|
|
1040
|
+
declare function useState<T>(key: string, init?: () => T | Ref<T>): Ref<T>;
|
|
1041
|
+
//#endregion
|
|
1042
|
+
//#region src/composables/use-navigation-middleware.d.ts
|
|
1043
|
+
/**
|
|
1044
|
+
* Navigation context for middleware
|
|
1045
|
+
*/
|
|
1046
|
+
interface NavigationContext {
|
|
1047
|
+
to: RouteLocationNormalized$1;
|
|
1048
|
+
from: RouteLocationNormalized$1;
|
|
1049
|
+
failure?: NavigationFailure;
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* Navigation error context
|
|
1053
|
+
*/
|
|
1054
|
+
interface NavigationErrorContext {
|
|
1055
|
+
error: Error;
|
|
1056
|
+
to: RouteLocationNormalized$1;
|
|
1057
|
+
from: RouteLocationNormalized$1;
|
|
1058
|
+
}
|
|
1059
|
+
type BeforeNavigationHandler = KimeshRuntimeHooks["navigate:before"];
|
|
1060
|
+
type AfterNavigationHandler = KimeshRuntimeHooks["navigate:after"];
|
|
1061
|
+
type ErrorNavigationHandler = KimeshRuntimeHooks["navigate:error"];
|
|
1062
|
+
/**
|
|
1063
|
+
* Options for useNavigationMiddleware
|
|
1064
|
+
*/
|
|
1065
|
+
interface NavigationMiddlewareOptions {
|
|
1066
|
+
/** Called before navigation */
|
|
1067
|
+
before?: BeforeNavigationHandler;
|
|
1068
|
+
/** Called after navigation */
|
|
1069
|
+
after?: AfterNavigationHandler;
|
|
1070
|
+
/** Called on navigation error */
|
|
1071
|
+
error?: ErrorNavigationHandler;
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Register navigation middleware using the hook system
|
|
1075
|
+
*
|
|
1076
|
+
* @example
|
|
1077
|
+
* ```ts
|
|
1078
|
+
* // In a plugin or component setup
|
|
1079
|
+
* const { remove } = useNavigationMiddleware({
|
|
1080
|
+
* before: ({ to }) => {
|
|
1081
|
+
* if (!isAuthenticated() && to.meta.requiresAuth) {
|
|
1082
|
+
* return false // Cancel navigation
|
|
1083
|
+
* }
|
|
1084
|
+
* },
|
|
1085
|
+
* after: ({ to }) => {
|
|
1086
|
+
* analytics.trackPageView(to.path)
|
|
1087
|
+
* },
|
|
1088
|
+
* error: ({ error }) => {
|
|
1089
|
+
* console.error('Navigation failed:', error)
|
|
1090
|
+
* },
|
|
1091
|
+
* })
|
|
1092
|
+
*
|
|
1093
|
+
* // Cleanup when done
|
|
1094
|
+
* onUnmounted(() => remove())
|
|
1095
|
+
* ```
|
|
1096
|
+
*
|
|
1097
|
+
* @returns Object with remove function to cleanup hooks
|
|
1098
|
+
*/
|
|
1099
|
+
declare function useNavigationMiddleware(options: NavigationMiddlewareOptions): {
|
|
1100
|
+
remove: () => void;
|
|
1101
|
+
};
|
|
1102
|
+
/**
|
|
1103
|
+
* Create a navigation guard that runs before navigation
|
|
1104
|
+
*
|
|
1105
|
+
* @example
|
|
1106
|
+
* ```ts
|
|
1107
|
+
* // Auth guard plugin
|
|
1108
|
+
* export default defineKimeshRuntimePlugin({
|
|
1109
|
+
* name: 'auth-guard',
|
|
1110
|
+
* setup(app) {
|
|
1111
|
+
* app.runWithContext(() => {
|
|
1112
|
+
* useNavigationGuard(({ to }) => {
|
|
1113
|
+
* if (to.meta.requiresAuth && !isAuthenticated()) {
|
|
1114
|
+
* return false
|
|
1115
|
+
* }
|
|
1116
|
+
* })
|
|
1117
|
+
* })
|
|
1118
|
+
* }
|
|
1119
|
+
* })
|
|
1120
|
+
* ```
|
|
1121
|
+
*/
|
|
1122
|
+
declare function useNavigationGuard(guard: BeforeNavigationHandler): () => void;
|
|
1123
|
+
/**
|
|
1124
|
+
* Register a callback for after navigation
|
|
1125
|
+
*/
|
|
1126
|
+
declare function useAfterNavigation(callback: AfterNavigationHandler): () => void;
|
|
1127
|
+
//#endregion
|
|
1128
|
+
export { type BeforeLoadContext, type CreateKimeshAppOptions, type CreateKimeshAppOptionsExtended, type FileRouteOptions, type FullContext, type HasParams, KIMESH_APP_CONTEXT_KEY, KIMESH_CONTEXT_KEY, KIMESH_PLUGIN_INDICATOR, type KimeshApp, type KimeshAppContext, type KimeshContext, type KimeshRuntimeHooks, type KimeshRuntimePlugin, type KimeshRuntimePluginDefinition, type KimeshRuntimePluginMeta, type KimeshRuntimePluginResult, KmDeferred, KmLink, type KmLinkProps, KmOutlet, type LoaderContext, type LoaderFn, type LoaderGuardOptions, type NavigateOptions, type NavigationAfterHookContext, type NavigationContext, type NavigationErrorContext, type NavigationErrorHookContext, type NavigationGuard, type NavigationHookAfter, type NavigationHookContext, type NavigationMiddlewareOptions, type ParamValue, type ParamValueOneOrMore, type ParamValueZeroOrMore, type ParamValueZeroOrOne, type QueryPluginOptions, type RouteDefinition, type RouteHeadConfig, type RouteHeadContext, type RouteHeadFn, type RouteInfoByName, type RouteLocationNormalized, type RouteLocationNormalizedLoaded, type RouteLocationRaw, type RouteNamedMap, type RouteNames, type RouteParams, type RouteParamsRaw, type RoutePath, type RouteRecordInfo, type RouteRecordRaw, type Router, type RuntimeConfig, type RuntimeConfigPublic, STATE_KEY_PREFIX, type SearchSchema, type UseSearchReturn, applyPlugin, applyPlugins, applyPluginsWithParallel, clearKmState, createFileRoute, createKimeshApp, createLoaderGuard, defineContext, defineKimeshRuntimePlugin, defineRoute, getCorePlugins, getKmStateKeys, getPluginHooks, getPluginMeta, getPluginName, hasKmState, installLoaderGuard, isKimeshRuntimePlugin, onBeforeRouteLeave, onBeforeRouteUpdate, queryPlugin, routerPlugin, tryUseKimeshApp, useAfterNavigation, useKimeshApp, useKimeshContext, useLink, useNavigate, useNavigationGuard, useNavigationMiddleware, useParams, useReactiveParams, useRoute, useRouter, useRuntimeConfig, useSearch, useState };
|
|
1129
|
+
//# sourceMappingURL=index.d.mts.map
|