@kimesh/router-runtime 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index-WwJndf8N.d.mts +1437 -0
- package/dist/index.d.mts +2 -1128
- package/dist/index.mjs +19 -74
- package/dist/middleware/index.d.mts +2 -0
- package/dist/middleware/index.mjs +4 -0
- package/dist/middleware/plugin.d.mts +2 -0
- package/dist/middleware/plugin.mjs +3 -0
- package/dist/middleware-DdlzhfiB.mjs +111 -0
- package/dist/plugin-DsScck9c.mjs +195 -0
- package/package.json +9 -1
|
@@ -0,0 +1,1437 @@
|
|
|
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 as useRoute$1, useRouter as useRouter$1 } 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;
|
|
29
|
+
from: RouteLocationNormalized;
|
|
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;
|
|
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
|
+
* Extract param names from a route path string
|
|
146
|
+
* e.g., '/blog/:postId/comments/:commentId' → 'postId' | 'commentId'
|
|
147
|
+
*/
|
|
148
|
+
type ExtractParamNames<T extends string> = T extends `${string}:${infer Param}/${infer Rest}` ? ExtractParamName<Param> | ExtractParamNames<`/${Rest}`> : T extends `${string}:${infer Param}` ? ExtractParamName<Param> : never;
|
|
149
|
+
/**
|
|
150
|
+
* Clean param name (remove optional ? or * modifiers)
|
|
151
|
+
*/
|
|
152
|
+
type ExtractParamName<T extends string> = T extends `${infer Name}?` ? Name : T extends `${infer Name}*` ? Name : T extends `${infer Name}+` ? Name : T;
|
|
153
|
+
/**
|
|
154
|
+
* Extract params object from route path
|
|
155
|
+
* e.g., '/blog/:postId' → { postId: string }
|
|
156
|
+
*/
|
|
157
|
+
type ExtractRouteParams<T extends string> = ExtractParamNames<T> extends never ? Record<string, string> : { [K in ExtractParamNames<T>]: string };
|
|
158
|
+
/**
|
|
159
|
+
* Route record info type - populated by generated types
|
|
160
|
+
*/
|
|
161
|
+
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> {
|
|
162
|
+
name: Name;
|
|
163
|
+
path: Path;
|
|
164
|
+
paramsRaw: ParamsRaw;
|
|
165
|
+
params: Params;
|
|
166
|
+
children: Children;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Route named map - populated by generated types
|
|
170
|
+
* This interface is augmented by route-types.d.ts
|
|
171
|
+
*/
|
|
172
|
+
interface RouteNamedMap {}
|
|
173
|
+
/** Get all route names - falls back to string when RouteNamedMap is empty */
|
|
174
|
+
type RouteNames = keyof RouteNamedMap extends never ? string : keyof RouteNamedMap;
|
|
175
|
+
/** Allow both named routes and arbitrary string paths (& {} preserves autocomplete) */
|
|
176
|
+
type RouteLocationRaw = RouteNames | (string & {});
|
|
177
|
+
/** Get route info by name */
|
|
178
|
+
type RouteInfoByName<T extends string> = T extends keyof RouteNamedMap ? RouteNamedMap[T] : RouteRecordInfo<T, T>;
|
|
179
|
+
/** Get raw params for a route name (accepts string | number) */
|
|
180
|
+
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>;
|
|
181
|
+
/** Get resolved params for a route name (string only) */
|
|
182
|
+
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>;
|
|
183
|
+
/** Get path for a route name */
|
|
184
|
+
type RoutePath<T extends string> = T extends keyof RouteNamedMap ? RouteNamedMap[T] extends RouteRecordInfo<any, infer P, any, any, any> ? P : string : string;
|
|
185
|
+
/** Check if route has params */
|
|
186
|
+
type HasParams<T extends string> = T extends keyof RouteNamedMap ? keyof RouteParams<T> extends never ? false : true : boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Options for creating a Kimesh app
|
|
189
|
+
*/
|
|
190
|
+
interface CreateKimeshAppOptions {
|
|
191
|
+
/** Root component (usually App.vue or a layout) */
|
|
192
|
+
rootComponent: Component;
|
|
193
|
+
/** Route records array */
|
|
194
|
+
routes: RouteRecordRaw[];
|
|
195
|
+
/** Base URL for router */
|
|
196
|
+
base?: string;
|
|
197
|
+
/** History mode */
|
|
198
|
+
history?: "hash" | "web";
|
|
199
|
+
/** Scroll behavior */
|
|
200
|
+
scrollBehavior?: Router["options"]["scrollBehavior"];
|
|
201
|
+
/** Query client configuration */
|
|
202
|
+
queryClientConfig?: QueryClientConfig;
|
|
203
|
+
/** Custom context (user-defined) */
|
|
204
|
+
context?: KimeshContext | (() => KimeshContext);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Kimesh App instance
|
|
208
|
+
*/
|
|
209
|
+
interface KimeshApp {
|
|
210
|
+
/** Vue app instance */
|
|
211
|
+
app: App;
|
|
212
|
+
/** Vue Router instance */
|
|
213
|
+
router: Router;
|
|
214
|
+
/** Query client instance */
|
|
215
|
+
queryClient: QueryClient;
|
|
216
|
+
/** Kimesh app context (new runtime plugin system) */
|
|
217
|
+
context?: KimeshAppContext;
|
|
218
|
+
/** Mount the app */
|
|
219
|
+
mount(container: string | Element): KimeshApp | Promise<KimeshApp>;
|
|
220
|
+
/** Unmount the app */
|
|
221
|
+
unmount(): void;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Loader context passed to loader functions
|
|
225
|
+
*/
|
|
226
|
+
interface LoaderContext<TParams = Record<string, string>, TSearch = Record<string, unknown>> {
|
|
227
|
+
/** Route params (e.g., { postId: '123' }) */
|
|
228
|
+
params: TParams;
|
|
229
|
+
/** Validated search/query params */
|
|
230
|
+
search: TSearch;
|
|
231
|
+
/** App context (built-in + user-defined) */
|
|
232
|
+
context: FullContext;
|
|
233
|
+
/** AbortSignal for cancellation */
|
|
234
|
+
signal: AbortSignal;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Loader function type
|
|
238
|
+
*/
|
|
239
|
+
type LoaderFn<TParams = Record<string, string>, TSearch = Record<string, unknown>, TData = unknown> = (ctx: LoaderContext<TParams, TSearch>) => Promise<TData> | TData;
|
|
240
|
+
/**
|
|
241
|
+
* Schema interface for validateSearch (compatible with Zod)
|
|
242
|
+
*/
|
|
243
|
+
interface SearchSchema<T = unknown> {
|
|
244
|
+
parse: (input: unknown) => T;
|
|
245
|
+
safeParse?: (input: unknown) => {
|
|
246
|
+
success: boolean;
|
|
247
|
+
data?: T;
|
|
248
|
+
error?: unknown;
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Context passed to route head function
|
|
253
|
+
*/
|
|
254
|
+
interface RouteHeadContext<TParams = Record<string, string>, TLoaderData = unknown> {
|
|
255
|
+
/** Route params extracted from URL */
|
|
256
|
+
params: TParams;
|
|
257
|
+
/** Data returned from route loader */
|
|
258
|
+
loaderData: TLoaderData;
|
|
259
|
+
/** Current route */
|
|
260
|
+
route: RouteLocationNormalizedLoaded;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Route head configuration - compatible with @unhead/vue Head type
|
|
264
|
+
*/
|
|
265
|
+
interface RouteHeadConfig {
|
|
266
|
+
/** Page title */
|
|
267
|
+
title?: string;
|
|
268
|
+
/** Title template (e.g., '%s | My App') */
|
|
269
|
+
titleTemplate?: string | ((title: string) => string);
|
|
270
|
+
/** Meta tags */
|
|
271
|
+
meta?: Array<{
|
|
272
|
+
name?: string;
|
|
273
|
+
property?: string;
|
|
274
|
+
content?: string;
|
|
275
|
+
charset?: string;
|
|
276
|
+
"http-equiv"?: string;
|
|
277
|
+
[key: string]: string | undefined;
|
|
278
|
+
}>;
|
|
279
|
+
/** Link tags */
|
|
280
|
+
link?: Array<{
|
|
281
|
+
rel?: string;
|
|
282
|
+
href?: string;
|
|
283
|
+
type?: string;
|
|
284
|
+
as?: string;
|
|
285
|
+
crossorigin?: string;
|
|
286
|
+
media?: string;
|
|
287
|
+
sizes?: string;
|
|
288
|
+
hreflang?: string;
|
|
289
|
+
title?: string;
|
|
290
|
+
[key: string]: string | undefined;
|
|
291
|
+
}>;
|
|
292
|
+
/** Script tags */
|
|
293
|
+
script?: Array<{
|
|
294
|
+
src?: string;
|
|
295
|
+
async?: boolean;
|
|
296
|
+
defer?: boolean;
|
|
297
|
+
type?: string;
|
|
298
|
+
innerHTML?: string;
|
|
299
|
+
[key: string]: string | boolean | undefined;
|
|
300
|
+
}>;
|
|
301
|
+
/** Style tags */
|
|
302
|
+
style?: Array<{
|
|
303
|
+
innerHTML?: string;
|
|
304
|
+
media?: string;
|
|
305
|
+
type?: string;
|
|
306
|
+
[key: string]: string | undefined;
|
|
307
|
+
}>;
|
|
308
|
+
/** HTML attributes */
|
|
309
|
+
htmlAttrs?: {
|
|
310
|
+
lang?: string;
|
|
311
|
+
dir?: "ltr" | "rtl" | "auto";
|
|
312
|
+
class?: string;
|
|
313
|
+
[key: string]: string | undefined;
|
|
314
|
+
};
|
|
315
|
+
/** Body attributes */
|
|
316
|
+
bodyAttrs?: {
|
|
317
|
+
class?: string;
|
|
318
|
+
[key: string]: string | undefined;
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Route head function signature
|
|
323
|
+
*/
|
|
324
|
+
type RouteHeadFn<TParams = Record<string, string>, TLoaderData = unknown> = (context: RouteHeadContext<TParams, TLoaderData>) => RouteHeadConfig;
|
|
325
|
+
/**
|
|
326
|
+
* Inline middleware context for typed routes
|
|
327
|
+
*/
|
|
328
|
+
interface InlineMiddlewareContext {
|
|
329
|
+
/** Vue Router instance */
|
|
330
|
+
router: Router;
|
|
331
|
+
/** Kimesh app context */
|
|
332
|
+
app: KimeshAppContext;
|
|
333
|
+
/** Custom data for sharing between middleware */
|
|
334
|
+
data: Record<string, unknown>;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Inline route middleware with typed params
|
|
338
|
+
* Used in createFileRoute for automatic param inference
|
|
339
|
+
*/
|
|
340
|
+
type InlineRouteMiddleware<TParams = Record<string, string>> = (to: RouteLocationNormalized & {
|
|
341
|
+
params: TParams;
|
|
342
|
+
}, from: RouteLocationNormalized, context: InlineMiddlewareContext) => void | undefined | false | {
|
|
343
|
+
path?: string;
|
|
344
|
+
name?: string;
|
|
345
|
+
} | Promise<void | undefined | false | {
|
|
346
|
+
path?: string;
|
|
347
|
+
name?: string;
|
|
348
|
+
}>;
|
|
349
|
+
/**
|
|
350
|
+
* File route options
|
|
351
|
+
*/
|
|
352
|
+
interface FileRouteOptions<TMeta = unknown, TParams = Record<string, string>, TSearch = Record<string, unknown>, TLoaderData = unknown> {
|
|
353
|
+
/** Route meta */
|
|
354
|
+
meta?: TMeta;
|
|
355
|
+
/** Loader function - runs before navigation completes */
|
|
356
|
+
loader?: LoaderFn<TParams, TSearch, TLoaderData>;
|
|
357
|
+
/** Search params validation schema (Zod compatible) */
|
|
358
|
+
validateSearch?: SearchSchema<TSearch>;
|
|
359
|
+
/**
|
|
360
|
+
* Route middleware (runs before beforeLoad)
|
|
361
|
+
*
|
|
362
|
+
* @example Named middleware
|
|
363
|
+
* ```ts
|
|
364
|
+
* middleware: 'admin'
|
|
365
|
+
* ```
|
|
366
|
+
*
|
|
367
|
+
* @example Multiple middleware
|
|
368
|
+
* ```ts
|
|
369
|
+
* middleware: ['auth', 'analytics']
|
|
370
|
+
* ```
|
|
371
|
+
*
|
|
372
|
+
* @example Inline middleware (typed params!)
|
|
373
|
+
* ```ts
|
|
374
|
+
* middleware: (to, from, ctx) => {
|
|
375
|
+
* // to.params is typed based on route path!
|
|
376
|
+
* console.log(to.params.postId)
|
|
377
|
+
* }
|
|
378
|
+
* ```
|
|
379
|
+
*/
|
|
380
|
+
middleware?: string | InlineRouteMiddleware<TParams> | Array<string | InlineRouteMiddleware<TParams>>;
|
|
381
|
+
/** Before load hook (runs after middleware) */
|
|
382
|
+
beforeLoad?: (ctx: BeforeLoadContext) => Promise<void> | void;
|
|
383
|
+
/**
|
|
384
|
+
* Route-level head configuration
|
|
385
|
+
*
|
|
386
|
+
* @example Static head
|
|
387
|
+
* ```ts
|
|
388
|
+
* head: {
|
|
389
|
+
* title: 'About Us',
|
|
390
|
+
* meta: [{ name: 'description', content: 'Learn about our company' }]
|
|
391
|
+
* }
|
|
392
|
+
* ```
|
|
393
|
+
*
|
|
394
|
+
* @example Dynamic head from loader
|
|
395
|
+
* ```ts
|
|
396
|
+
* head: ({ loaderData }) => ({
|
|
397
|
+
* title: loaderData.post.title,
|
|
398
|
+
* meta: [{ property: 'og:title', content: loaderData.post.title }]
|
|
399
|
+
* })
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
head?: RouteHeadFn<TParams, TLoaderData> | RouteHeadConfig;
|
|
403
|
+
/**
|
|
404
|
+
* Page transition configuration
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```ts
|
|
408
|
+
* transition: { name: 'slide', mode: 'out-in' }
|
|
409
|
+
* // or disable transition
|
|
410
|
+
* transition: false
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
transition?: boolean | TransitionProps;
|
|
414
|
+
/**
|
|
415
|
+
* View Transition API (experimental)
|
|
416
|
+
* Uses native browser document.startViewTransition() API
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* ```ts
|
|
420
|
+
* viewTransition: true // respect user's prefers-reduced-motion
|
|
421
|
+
* viewTransition: 'always' // always use view transitions
|
|
422
|
+
* ```
|
|
423
|
+
*/
|
|
424
|
+
viewTransition?: boolean | "always";
|
|
425
|
+
/**
|
|
426
|
+
* KeepAlive configuration for route component
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* ```ts
|
|
430
|
+
* keepalive: true
|
|
431
|
+
* keepalive: { max: 10 }
|
|
432
|
+
* ```
|
|
433
|
+
*/
|
|
434
|
+
keepalive?: boolean | KeepAliveProps;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Before load context
|
|
438
|
+
*/
|
|
439
|
+
interface BeforeLoadContext {
|
|
440
|
+
/** Current route */
|
|
441
|
+
route: RouteLocationNormalizedLoaded;
|
|
442
|
+
/** Router instance */
|
|
443
|
+
router: Router;
|
|
444
|
+
/** Abort navigation */
|
|
445
|
+
abort: () => void;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Route definition returned by createFileRoute
|
|
449
|
+
*/
|
|
450
|
+
interface RouteDefinition<TPath extends string = string, TMeta = unknown, TParams = Record<string, string>, TSearch = Record<string, unknown>, TLoaderData = unknown> {
|
|
451
|
+
path: TPath;
|
|
452
|
+
meta?: TMeta;
|
|
453
|
+
loader?: LoaderFn<TParams, TSearch, TLoaderData>;
|
|
454
|
+
validateSearch?: SearchSchema<TSearch>;
|
|
455
|
+
middleware?: string | InlineRouteMiddleware<TParams> | Array<string | InlineRouteMiddleware<TParams>>;
|
|
456
|
+
beforeLoad?: (ctx: BeforeLoadContext) => Promise<void> | void;
|
|
457
|
+
head?: RouteHeadFn<TParams, TLoaderData> | RouteHeadConfig;
|
|
458
|
+
transition?: boolean | TransitionProps;
|
|
459
|
+
viewTransition?: boolean | "always";
|
|
460
|
+
keepalive?: boolean | KeepAliveProps;
|
|
461
|
+
}
|
|
462
|
+
declare module "vue-router" {
|
|
463
|
+
interface RouteMeta {
|
|
464
|
+
/** Kimesh route definition with loader */
|
|
465
|
+
__kimesh?: RouteDefinition;
|
|
466
|
+
/** Error from loader execution */
|
|
467
|
+
__kimeshError?: unknown;
|
|
468
|
+
/** Source layer name for layer-aware features */
|
|
469
|
+
__kimeshLayer?: string;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
//#endregion
|
|
473
|
+
//#region src/create-app.d.ts
|
|
474
|
+
declare const KIMESH_APP_CONTEXT_KEY: InjectionKey<KimeshAppContext>;
|
|
475
|
+
interface CreateKimeshAppOptionsExtended extends CreateKimeshAppOptions {
|
|
476
|
+
plugins?: KimeshRuntimePlugin[];
|
|
477
|
+
runtimeConfig?: RuntimeConfigPublic;
|
|
478
|
+
/** Per-layer runtime configs (for layer-aware features like $fetch) */
|
|
479
|
+
layersConfig?: Record<string, Record<string, unknown>>;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Create a Kimesh application with router, query client, and runtime plugins
|
|
483
|
+
*/
|
|
484
|
+
declare function createKimeshApp(options: CreateKimeshAppOptionsExtended): Promise<KimeshApp>;
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/create-file-route.d.ts
|
|
487
|
+
/**
|
|
488
|
+
* Create a file-based route definition
|
|
489
|
+
*
|
|
490
|
+
* @example
|
|
491
|
+
* ```ts
|
|
492
|
+
* // In routes/about.vue
|
|
493
|
+
* export const Route = createFileRoute('/about')({
|
|
494
|
+
* meta: { title: 'About Us' },
|
|
495
|
+
* loader: async () => {
|
|
496
|
+
* return { data: await fetchAboutData() }
|
|
497
|
+
* },
|
|
498
|
+
* head: {
|
|
499
|
+
* title: 'About Us',
|
|
500
|
+
* meta: [{ name: 'description', content: 'Learn about us' }]
|
|
501
|
+
* }
|
|
502
|
+
* })
|
|
503
|
+
* ```
|
|
504
|
+
*
|
|
505
|
+
* @example With typed params
|
|
506
|
+
* ```ts
|
|
507
|
+
* // In routes/users/$userId.vue
|
|
508
|
+
* export const Route = createFileRoute('/users/:userId')({
|
|
509
|
+
* middleware: (to, from, ctx) => {
|
|
510
|
+
* // to.params.userId is typed!
|
|
511
|
+
* console.log(to.params.userId)
|
|
512
|
+
* },
|
|
513
|
+
* loader: ({ params }) => {
|
|
514
|
+
* // params.userId is typed!
|
|
515
|
+
* return fetchUser(params.userId)
|
|
516
|
+
* }
|
|
517
|
+
* })
|
|
518
|
+
* ```
|
|
519
|
+
*/
|
|
520
|
+
declare function createFileRoute<TPath extends string>(path: TPath): <TMeta = unknown>(options?: FileRouteOptions<TMeta, ExtractRouteParams<TPath>>) => RouteDefinition<TPath, TMeta, ExtractRouteParams<TPath>>;
|
|
521
|
+
/**
|
|
522
|
+
* Define route for use in Vue SFC
|
|
523
|
+
* Alternative syntax for createFileRoute
|
|
524
|
+
*/
|
|
525
|
+
declare function defineRoute<TMeta = unknown>(options: FileRouteOptions<TMeta>): FileRouteOptions<TMeta>;
|
|
526
|
+
//#endregion
|
|
527
|
+
//#region src/context.d.ts
|
|
528
|
+
/**
|
|
529
|
+
* Define app context with type inference
|
|
530
|
+
*
|
|
531
|
+
* @example
|
|
532
|
+
* ```ts
|
|
533
|
+
* // src/app.context.ts
|
|
534
|
+
* import { defineContext } from '@kimesh/router-runtime'
|
|
535
|
+
*
|
|
536
|
+
* export default defineContext(() => ({
|
|
537
|
+
* auth: useAuthStore(),
|
|
538
|
+
* i18n: createI18n(),
|
|
539
|
+
* }))
|
|
540
|
+
* ```
|
|
541
|
+
*/
|
|
542
|
+
declare function defineContext<T extends KimeshContext>(factory: () => T): () => T;
|
|
543
|
+
/**
|
|
544
|
+
* Use Kimesh context in components
|
|
545
|
+
*
|
|
546
|
+
* @example
|
|
547
|
+
* ```vue
|
|
548
|
+
* <script setup>
|
|
549
|
+
* const ctx = useKimeshContext()
|
|
550
|
+
* ctx.auth.logout()
|
|
551
|
+
* </script>
|
|
552
|
+
* ```
|
|
553
|
+
*/
|
|
554
|
+
declare function useKimeshContext(): FullContext;
|
|
555
|
+
//#endregion
|
|
556
|
+
//#region src/runtime-plugin.d.ts
|
|
557
|
+
declare const KIMESH_PLUGIN_INDICATOR: "__kimesh_plugin";
|
|
558
|
+
/**
|
|
559
|
+
* Define a Kimesh runtime plugin
|
|
560
|
+
*
|
|
561
|
+
* @example Function-style plugin
|
|
562
|
+
* ```ts
|
|
563
|
+
* export default defineKimeshRuntimePlugin((app) => {
|
|
564
|
+
* const analytics = new AnalyticsService()
|
|
565
|
+
* app.router.afterEach((to) => analytics.trackPageView(to.path))
|
|
566
|
+
* return { provide: { analytics } }
|
|
567
|
+
* })
|
|
568
|
+
* ```
|
|
569
|
+
*
|
|
570
|
+
* @example Object-style plugin with hooks
|
|
571
|
+
* ```ts
|
|
572
|
+
* export default defineKimeshRuntimePlugin({
|
|
573
|
+
* name: 'my-plugin',
|
|
574
|
+
* enforce: 'pre',
|
|
575
|
+
* hooks: {
|
|
576
|
+
* 'app:mounted': () => console.log('App mounted!')
|
|
577
|
+
* },
|
|
578
|
+
* setup(app) {
|
|
579
|
+
* return { provide: { myService: new MyService() } }
|
|
580
|
+
* }
|
|
581
|
+
* })
|
|
582
|
+
* ```
|
|
583
|
+
*/
|
|
584
|
+
declare function defineKimeshRuntimePlugin<Injections extends Record<string, unknown> = Record<string, unknown>>(plugin: KimeshRuntimePlugin<Injections> | KimeshRuntimePluginDefinition<Injections>): KimeshRuntimePlugin<Injections>;
|
|
585
|
+
/**
|
|
586
|
+
* Check if a value is a Kimesh runtime plugin
|
|
587
|
+
*/
|
|
588
|
+
declare function isKimeshRuntimePlugin(value: unknown): value is KimeshRuntimePlugin;
|
|
589
|
+
/**
|
|
590
|
+
* Get plugin metadata
|
|
591
|
+
*/
|
|
592
|
+
declare function getPluginMeta(plugin: KimeshRuntimePlugin): KimeshRuntimePluginMeta;
|
|
593
|
+
/**
|
|
594
|
+
* Get plugin name
|
|
595
|
+
*/
|
|
596
|
+
declare function getPluginName(plugin: KimeshRuntimePlugin): string;
|
|
597
|
+
/**
|
|
598
|
+
* Get plugin hooks
|
|
599
|
+
*/
|
|
600
|
+
declare function getPluginHooks(plugin: KimeshRuntimePlugin): Partial<KimeshRuntimeHooks> | undefined;
|
|
601
|
+
//#endregion
|
|
602
|
+
//#region src/plugin-executor.d.ts
|
|
603
|
+
/**
|
|
604
|
+
* Apply a single plugin to the app context
|
|
605
|
+
*/
|
|
606
|
+
declare function applyPlugin(app: KimeshAppContext, plugin: KimeshRuntimePlugin): Promise<void>;
|
|
607
|
+
/**
|
|
608
|
+
* Apply all plugins to the app context with dependency resolution
|
|
609
|
+
*/
|
|
610
|
+
declare function applyPlugins(app: KimeshAppContext, plugins: KimeshRuntimePlugin[]): Promise<void>;
|
|
611
|
+
/**
|
|
612
|
+
* Apply plugins with parallel support.
|
|
613
|
+
* Plugins with parallel: true run concurrently within their group.
|
|
614
|
+
*/
|
|
615
|
+
declare function applyPluginsWithParallel(app: KimeshAppContext, plugins: KimeshRuntimePlugin[]): Promise<void>;
|
|
616
|
+
//#endregion
|
|
617
|
+
//#region src/plugins/core.d.ts
|
|
618
|
+
/**
|
|
619
|
+
* @kimesh/router-runtime - Core Plugins
|
|
620
|
+
*
|
|
621
|
+
* Built-in runtime plugins for Kimesh.
|
|
622
|
+
*/
|
|
623
|
+
/**
|
|
624
|
+
* Router plugin that wires Vue Router guards to Kimesh hook system
|
|
625
|
+
*
|
|
626
|
+
* This plugin runs with `enforce: 'pre'` to ensure router hooks
|
|
627
|
+
* are available to all other plugins.
|
|
628
|
+
*/
|
|
629
|
+
declare const routerPlugin: KimeshRuntimePlugin<Record<string, unknown>>;
|
|
630
|
+
interface QueryPluginOptions {
|
|
631
|
+
/** Enable route-based prefetching */
|
|
632
|
+
prefetching?: boolean;
|
|
633
|
+
/** Paths to exclude from prefetching */
|
|
634
|
+
excludePrefetch?: (string | RegExp)[];
|
|
635
|
+
[key: string]: unknown;
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Query plugin that sets up prefetching on navigation
|
|
639
|
+
*
|
|
640
|
+
* Note: QueryClient is already initialized in createKimeshApp,
|
|
641
|
+
* this plugin adds navigation-based prefetching.
|
|
642
|
+
*/
|
|
643
|
+
declare const queryPlugin: KimeshRuntimePlugin<QueryPluginOptions>;
|
|
644
|
+
/**
|
|
645
|
+
* Get the default core plugins for a Kimesh app
|
|
646
|
+
*/
|
|
647
|
+
declare function getCorePlugins(): KimeshRuntimePlugin<Record<string, unknown>>[];
|
|
648
|
+
//#endregion
|
|
649
|
+
//#region src/components/KmOutlet.d.ts
|
|
650
|
+
/**
|
|
651
|
+
* KmOutlet - Router view wrapper component
|
|
652
|
+
* Renders the matched route component with optional transitions and keepalive
|
|
653
|
+
*
|
|
654
|
+
* Transition options for async pages (useSuspenseQuery):
|
|
655
|
+
*
|
|
656
|
+
* 1. viewTransition: true (Recommended)
|
|
657
|
+
* - Uses View Transitions API (Chrome 111+, Edge 111+, Opera 97+)
|
|
658
|
+
* - Works perfectly with async pages
|
|
659
|
+
* - Falls back to instant transition on unsupported browsers
|
|
660
|
+
*
|
|
661
|
+
* 2. transition: { name: 'fade' } (without mode: 'out-in')
|
|
662
|
+
* - Uses Vue Transition with default mode (cross-fade)
|
|
663
|
+
* - Both pages exist during transition (old fades out, new fades in)
|
|
664
|
+
* - Requires CSS: .page-leave-active { position: absolute }
|
|
665
|
+
*
|
|
666
|
+
* 3. transition: { name: 'fade', mode: 'out-in' }
|
|
667
|
+
* - ⚠️ NOT recommended for async pages - may cause blank screen
|
|
668
|
+
*/
|
|
669
|
+
declare const KmOutlet: vue13.DefineComponent<vue13.ExtractPropTypes<{
|
|
670
|
+
name: {
|
|
671
|
+
type: StringConstructor;
|
|
672
|
+
default: string;
|
|
673
|
+
};
|
|
674
|
+
/**
|
|
675
|
+
* Page transition configuration (Vue Transition)
|
|
676
|
+
* ⚠️ Avoid mode: 'out-in' with async pages
|
|
677
|
+
*/
|
|
678
|
+
transition: {
|
|
679
|
+
type: any;
|
|
680
|
+
default: undefined;
|
|
681
|
+
};
|
|
682
|
+
/**
|
|
683
|
+
* Enable View Transitions API (recommended for async pages)
|
|
684
|
+
* Works in Chrome 111+, Edge 111+, Opera 97+
|
|
685
|
+
* Falls back to instant transition on unsupported browsers
|
|
686
|
+
*/
|
|
687
|
+
viewTransition: {
|
|
688
|
+
type: BooleanConstructor;
|
|
689
|
+
default: boolean;
|
|
690
|
+
};
|
|
691
|
+
/**
|
|
692
|
+
* KeepAlive configuration
|
|
693
|
+
*/
|
|
694
|
+
keepalive: {
|
|
695
|
+
type: any;
|
|
696
|
+
default: undefined;
|
|
697
|
+
};
|
|
698
|
+
/**
|
|
699
|
+
* Custom page key function for route identification
|
|
700
|
+
*/
|
|
701
|
+
pageKey: {
|
|
702
|
+
type: any;
|
|
703
|
+
default: null;
|
|
704
|
+
};
|
|
705
|
+
}>, () => VNode, {}, {}, {}, vue13.ComponentOptionsMixin, vue13.ComponentOptionsMixin, {}, string, vue13.PublicProps, Readonly<vue13.ExtractPropTypes<{
|
|
706
|
+
name: {
|
|
707
|
+
type: StringConstructor;
|
|
708
|
+
default: string;
|
|
709
|
+
};
|
|
710
|
+
/**
|
|
711
|
+
* Page transition configuration (Vue Transition)
|
|
712
|
+
* ⚠️ Avoid mode: 'out-in' with async pages
|
|
713
|
+
*/
|
|
714
|
+
transition: {
|
|
715
|
+
type: any;
|
|
716
|
+
default: undefined;
|
|
717
|
+
};
|
|
718
|
+
/**
|
|
719
|
+
* Enable View Transitions API (recommended for async pages)
|
|
720
|
+
* Works in Chrome 111+, Edge 111+, Opera 97+
|
|
721
|
+
* Falls back to instant transition on unsupported browsers
|
|
722
|
+
*/
|
|
723
|
+
viewTransition: {
|
|
724
|
+
type: BooleanConstructor;
|
|
725
|
+
default: boolean;
|
|
726
|
+
};
|
|
727
|
+
/**
|
|
728
|
+
* KeepAlive configuration
|
|
729
|
+
*/
|
|
730
|
+
keepalive: {
|
|
731
|
+
type: any;
|
|
732
|
+
default: undefined;
|
|
733
|
+
};
|
|
734
|
+
/**
|
|
735
|
+
* Custom page key function for route identification
|
|
736
|
+
*/
|
|
737
|
+
pageKey: {
|
|
738
|
+
type: any;
|
|
739
|
+
default: null;
|
|
740
|
+
};
|
|
741
|
+
}>> & Readonly<{}>, {
|
|
742
|
+
name: string;
|
|
743
|
+
transition: any;
|
|
744
|
+
viewTransition: boolean;
|
|
745
|
+
keepalive: any;
|
|
746
|
+
pageKey: any;
|
|
747
|
+
}, {}, {}, {}, string, vue13.ComponentProvideOptions, true, {}, any>;
|
|
748
|
+
//#endregion
|
|
749
|
+
//#region src/components/KmLink.d.ts
|
|
750
|
+
/**
|
|
751
|
+
* Type-safe link props - requires params if route has them
|
|
752
|
+
* Allows both named routes (with autocomplete) and raw string paths
|
|
753
|
+
*/
|
|
754
|
+
type KmLinkProps<T extends string = RouteNames> = T extends RouteNames ? HasParams<T> extends true ? {
|
|
755
|
+
to: T;
|
|
756
|
+
params: RouteParamsRaw<T>;
|
|
757
|
+
replace?: boolean;
|
|
758
|
+
} : HasParams<T> extends false ? {
|
|
759
|
+
to: T;
|
|
760
|
+
params?: undefined;
|
|
761
|
+
replace?: boolean;
|
|
762
|
+
} : {
|
|
763
|
+
to: T;
|
|
764
|
+
params?: Record<string, string | number>;
|
|
765
|
+
replace?: boolean;
|
|
766
|
+
} : {
|
|
767
|
+
to: T;
|
|
768
|
+
params?: Record<string, string | number>;
|
|
769
|
+
replace?: boolean;
|
|
770
|
+
};
|
|
771
|
+
/**
|
|
772
|
+
* KmLink - Type-safe router link component
|
|
773
|
+
*
|
|
774
|
+
* @example
|
|
775
|
+
* ```vue
|
|
776
|
+
* <!-- Static route -->
|
|
777
|
+
* <KmLink to="/posts">Posts</KmLink>
|
|
778
|
+
*
|
|
779
|
+
* <!-- Dynamic route with params -->
|
|
780
|
+
* <KmLink to="/posts/:postId" :params="{ postId: '123' }">
|
|
781
|
+
* Post 123
|
|
782
|
+
* </KmLink>
|
|
783
|
+
* ```
|
|
784
|
+
*/
|
|
785
|
+
declare const KmLink: vue13.DefineComponent<vue13.ExtractPropTypes<{
|
|
786
|
+
to: {
|
|
787
|
+
type: PropType<RouteLocationRaw>;
|
|
788
|
+
required: true;
|
|
789
|
+
};
|
|
790
|
+
params: {
|
|
791
|
+
type: PropType<Record<string, string | number>>;
|
|
792
|
+
default: undefined;
|
|
793
|
+
};
|
|
794
|
+
replace: {
|
|
795
|
+
type: BooleanConstructor;
|
|
796
|
+
default: boolean;
|
|
797
|
+
};
|
|
798
|
+
activeClass: {
|
|
799
|
+
type: StringConstructor;
|
|
800
|
+
default: string;
|
|
801
|
+
};
|
|
802
|
+
exactActiveClass: {
|
|
803
|
+
type: StringConstructor;
|
|
804
|
+
default: string;
|
|
805
|
+
};
|
|
806
|
+
prefetch: {
|
|
807
|
+
type: BooleanConstructor;
|
|
808
|
+
default: boolean;
|
|
809
|
+
};
|
|
810
|
+
tag: {
|
|
811
|
+
type: StringConstructor;
|
|
812
|
+
default: string;
|
|
813
|
+
};
|
|
814
|
+
}>, () => vue13.VNode<vue13.RendererNode, vue13.RendererElement, {
|
|
815
|
+
[key: string]: any;
|
|
816
|
+
}>, {}, {}, {}, vue13.ComponentOptionsMixin, vue13.ComponentOptionsMixin, {}, string, vue13.PublicProps, Readonly<vue13.ExtractPropTypes<{
|
|
817
|
+
to: {
|
|
818
|
+
type: PropType<RouteLocationRaw>;
|
|
819
|
+
required: true;
|
|
820
|
+
};
|
|
821
|
+
params: {
|
|
822
|
+
type: PropType<Record<string, string | number>>;
|
|
823
|
+
default: undefined;
|
|
824
|
+
};
|
|
825
|
+
replace: {
|
|
826
|
+
type: BooleanConstructor;
|
|
827
|
+
default: boolean;
|
|
828
|
+
};
|
|
829
|
+
activeClass: {
|
|
830
|
+
type: StringConstructor;
|
|
831
|
+
default: string;
|
|
832
|
+
};
|
|
833
|
+
exactActiveClass: {
|
|
834
|
+
type: StringConstructor;
|
|
835
|
+
default: string;
|
|
836
|
+
};
|
|
837
|
+
prefetch: {
|
|
838
|
+
type: BooleanConstructor;
|
|
839
|
+
default: boolean;
|
|
840
|
+
};
|
|
841
|
+
tag: {
|
|
842
|
+
type: StringConstructor;
|
|
843
|
+
default: string;
|
|
844
|
+
};
|
|
845
|
+
}>> & Readonly<{}>, {
|
|
846
|
+
params: Record<string, string | number>;
|
|
847
|
+
replace: boolean;
|
|
848
|
+
activeClass: string;
|
|
849
|
+
exactActiveClass: string;
|
|
850
|
+
prefetch: boolean;
|
|
851
|
+
tag: string;
|
|
852
|
+
}, {}, {}, {}, string, vue13.ComponentProvideOptions, true, {}, any>;
|
|
853
|
+
//#endregion
|
|
854
|
+
//#region src/components/KmDeferred.d.ts
|
|
855
|
+
/**
|
|
856
|
+
* KmDeferred - Suspense wrapper with error handling
|
|
857
|
+
*
|
|
858
|
+
* Wraps Vue's <Suspense> with error boundary functionality.
|
|
859
|
+
* Use with useSuspenseQuery for progressive data loading.
|
|
860
|
+
*
|
|
861
|
+
* @example
|
|
862
|
+
* ```vue
|
|
863
|
+
* <KmDeferred :timeout="200">
|
|
864
|
+
* <AsyncDataComponent />
|
|
865
|
+
* <template #fallback>
|
|
866
|
+
* <Skeleton />
|
|
867
|
+
* </template>
|
|
868
|
+
* <template #error="{ error, retry }">
|
|
869
|
+
* <ErrorCard :error="error" @retry="retry" />
|
|
870
|
+
* </template>
|
|
871
|
+
* </KmDeferred>
|
|
872
|
+
* ```
|
|
873
|
+
*/
|
|
874
|
+
declare const KmDeferred: vue13.DefineComponent<vue13.ExtractPropTypes<{
|
|
875
|
+
/**
|
|
876
|
+
* Delay in ms before showing fallback (default: 0)
|
|
877
|
+
* Helps avoid flashing loading states for fast loads
|
|
878
|
+
*/
|
|
879
|
+
timeout: {
|
|
880
|
+
type: PropType<number>;
|
|
881
|
+
default: number;
|
|
882
|
+
};
|
|
883
|
+
}>, () => VNode, {}, {}, {}, vue13.ComponentOptionsMixin, vue13.ComponentOptionsMixin, {}, string, vue13.PublicProps, Readonly<vue13.ExtractPropTypes<{
|
|
884
|
+
/**
|
|
885
|
+
* Delay in ms before showing fallback (default: 0)
|
|
886
|
+
* Helps avoid flashing loading states for fast loads
|
|
887
|
+
*/
|
|
888
|
+
timeout: {
|
|
889
|
+
type: PropType<number>;
|
|
890
|
+
default: number;
|
|
891
|
+
};
|
|
892
|
+
}>> & Readonly<{}>, {
|
|
893
|
+
timeout: number;
|
|
894
|
+
}, {}, {}, {}, string, vue13.ComponentProvideOptions, true, {}, any>;
|
|
895
|
+
//#endregion
|
|
896
|
+
//#region src/guards/loader-guard.d.ts
|
|
897
|
+
interface LoaderGuardOptions {
|
|
898
|
+
onError?: (error: Error, to: RouteLocationNormalized) => void;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Create the loader navigation guard
|
|
902
|
+
*/
|
|
903
|
+
declare function createLoaderGuard(context: FullContext, options?: LoaderGuardOptions): (to: RouteLocationNormalized, from: RouteLocationNormalized, abortController: AbortController) => Promise<void>;
|
|
904
|
+
/**
|
|
905
|
+
* Install loader guard on router
|
|
906
|
+
*/
|
|
907
|
+
declare function installLoaderGuard(router: Router, context: FullContext, options?: {
|
|
908
|
+
onError?: (error: Error, to: RouteLocationNormalized) => void;
|
|
909
|
+
}): () => void;
|
|
910
|
+
//#endregion
|
|
911
|
+
//#region src/composables/use-search.d.ts
|
|
912
|
+
interface UseSearchReturn<T> {
|
|
913
|
+
search: ComputedRef<T>;
|
|
914
|
+
setSearch: <K extends keyof T>(key: K, value: T[K]) => void;
|
|
915
|
+
setAllSearch: (params: Partial<T>) => void;
|
|
916
|
+
resetSearch: () => void;
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Access and update validated search params
|
|
920
|
+
*
|
|
921
|
+
* @example
|
|
922
|
+
* ```vue
|
|
923
|
+
* <script setup>
|
|
924
|
+
* import { useSearch } from '@kimesh/router-runtime'
|
|
925
|
+
* import { z } from 'zod'
|
|
926
|
+
*
|
|
927
|
+
* const searchSchema = z.object({
|
|
928
|
+
* page: z.coerce.number().default(1),
|
|
929
|
+
* sort: z.enum(['asc', 'desc']).default('desc')
|
|
930
|
+
* })
|
|
931
|
+
*
|
|
932
|
+
* const { search, setSearch } = useSearch(searchSchema)
|
|
933
|
+
* </script>
|
|
934
|
+
* ```
|
|
935
|
+
*/
|
|
936
|
+
declare function useSearch<T>(schema: SearchSchema<T>): UseSearchReturn<T>;
|
|
937
|
+
//#endregion
|
|
938
|
+
//#region src/composables/use-params.d.ts
|
|
939
|
+
/**
|
|
940
|
+
* Get typed route params (non-reactive snapshot)
|
|
941
|
+
*
|
|
942
|
+
* @example
|
|
943
|
+
* ```ts
|
|
944
|
+
* // In /posts/:postId page
|
|
945
|
+
* const params = useParams<'/posts/:postId'>()
|
|
946
|
+
* // params is typed as { postId: string }
|
|
947
|
+
* console.log(params.postId)
|
|
948
|
+
* ```
|
|
949
|
+
*/
|
|
950
|
+
declare function useParams<T extends string = RouteNames>(): RouteParams<T>;
|
|
951
|
+
/**
|
|
952
|
+
* Get reactive typed route params
|
|
953
|
+
*
|
|
954
|
+
* @example
|
|
955
|
+
* ```ts
|
|
956
|
+
* // In /posts/:postId page
|
|
957
|
+
* const params = useReactiveParams<'/posts/:postId'>()
|
|
958
|
+
* // params.value is typed as { postId: string }
|
|
959
|
+
* watchEffect(() => {
|
|
960
|
+
* console.log(params.value.postId)
|
|
961
|
+
* })
|
|
962
|
+
* ```
|
|
963
|
+
*/
|
|
964
|
+
declare function useReactiveParams<T extends string = RouteNames>(): ComputedRef<RouteParams<T>>;
|
|
965
|
+
//#endregion
|
|
966
|
+
//#region src/composables/use-navigate.d.ts
|
|
967
|
+
/**
|
|
968
|
+
* Navigation options - requires params if route has them
|
|
969
|
+
* Allows both named routes (with autocomplete) and raw string paths
|
|
970
|
+
*/
|
|
971
|
+
type NavigateOptions<T extends string = RouteNames> = T extends RouteNames ? (HasParams<T> extends true ? {
|
|
972
|
+
to: T;
|
|
973
|
+
params: RouteParamsRaw<T>;
|
|
974
|
+
replace?: boolean;
|
|
975
|
+
} : HasParams<T> extends false ? {
|
|
976
|
+
to: T;
|
|
977
|
+
params?: undefined;
|
|
978
|
+
replace?: boolean;
|
|
979
|
+
} : {
|
|
980
|
+
to: T;
|
|
981
|
+
params?: Record<string, string | number>;
|
|
982
|
+
replace?: boolean;
|
|
983
|
+
}) : {
|
|
984
|
+
to: T;
|
|
985
|
+
params?: Record<string, string | number>;
|
|
986
|
+
replace?: boolean;
|
|
987
|
+
};
|
|
988
|
+
/**
|
|
989
|
+
* Type-safe navigation composable
|
|
990
|
+
*
|
|
991
|
+
* @example
|
|
992
|
+
* ```ts
|
|
993
|
+
* const { navigate } = useNavigate()
|
|
994
|
+
*
|
|
995
|
+
* // Navigate to static route
|
|
996
|
+
* navigate({ to: '/posts' })
|
|
997
|
+
*
|
|
998
|
+
* // Navigate to dynamic route with params
|
|
999
|
+
* navigate({ to: '/posts/:postId', params: { postId: '123' } })
|
|
1000
|
+
*
|
|
1001
|
+
* // Replace instead of push
|
|
1002
|
+
* navigate({ to: '/posts', replace: true })
|
|
1003
|
+
* ```
|
|
1004
|
+
*/
|
|
1005
|
+
declare function useNavigate(): {
|
|
1006
|
+
navigate: <T extends RouteLocationRaw = string>(options: NavigateOptions<T>) => Promise<void | vue_router0.NavigationFailure | undefined>;
|
|
1007
|
+
back: () => void;
|
|
1008
|
+
forward: () => void;
|
|
1009
|
+
go: (delta: number) => void;
|
|
1010
|
+
router: vue_router0.Router;
|
|
1011
|
+
};
|
|
1012
|
+
//#endregion
|
|
1013
|
+
//#region src/composables/use-runtime-config.d.ts
|
|
1014
|
+
/**
|
|
1015
|
+
* @kimesh/router-runtime - useRuntimeConfig composable
|
|
1016
|
+
*
|
|
1017
|
+
* Provides type-safe access to runtime configuration.
|
|
1018
|
+
* Phase 1: Client-side only, returns build-time injected config.
|
|
1019
|
+
*/
|
|
1020
|
+
/**
|
|
1021
|
+
* Runtime configuration type.
|
|
1022
|
+
* Users can extend this interface via declaration merging for type-safe config access.
|
|
1023
|
+
*
|
|
1024
|
+
* @example
|
|
1025
|
+
* ```ts
|
|
1026
|
+
* // src/types/runtime-config.d.ts
|
|
1027
|
+
* declare module '@kimesh/router-runtime' {
|
|
1028
|
+
* interface RuntimeConfig {
|
|
1029
|
+
* apiBase: string;
|
|
1030
|
+
* debug: boolean;
|
|
1031
|
+
* features: {
|
|
1032
|
+
* darkMode: boolean;
|
|
1033
|
+
* };
|
|
1034
|
+
* }
|
|
1035
|
+
* }
|
|
1036
|
+
* ```
|
|
1037
|
+
*/
|
|
1038
|
+
interface RuntimeConfig {
|
|
1039
|
+
[key: string]: unknown;
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* Access runtime configuration.
|
|
1043
|
+
*
|
|
1044
|
+
* Returns the runtime config that was injected at build time via Vite's `define`.
|
|
1045
|
+
* Values can be overridden using `KIMESH_*` environment variables during build.
|
|
1046
|
+
*
|
|
1047
|
+
* @returns Frozen runtime config object
|
|
1048
|
+
*
|
|
1049
|
+
* @example
|
|
1050
|
+
* ```vue
|
|
1051
|
+
* <script setup>
|
|
1052
|
+
* const config = useRuntimeConfig()
|
|
1053
|
+
* console.log(config.apiBase)
|
|
1054
|
+
* console.log(config.debug)
|
|
1055
|
+
* </script>
|
|
1056
|
+
* ```
|
|
1057
|
+
*
|
|
1058
|
+
* @example
|
|
1059
|
+
* ```ts
|
|
1060
|
+
* // In a composable
|
|
1061
|
+
* export function useApi() {
|
|
1062
|
+
* const config = useRuntimeConfig()
|
|
1063
|
+
*
|
|
1064
|
+
* async function fetch<T>(endpoint: string): Promise<T> {
|
|
1065
|
+
* const url = `${config.apiBase}${endpoint}`
|
|
1066
|
+
* const response = await globalThis.fetch(url)
|
|
1067
|
+
* return response.json()
|
|
1068
|
+
* }
|
|
1069
|
+
*
|
|
1070
|
+
* return { fetch }
|
|
1071
|
+
* }
|
|
1072
|
+
* ```
|
|
1073
|
+
*/
|
|
1074
|
+
declare function useRuntimeConfig<T extends RuntimeConfig = RuntimeConfig>(): T;
|
|
1075
|
+
//#endregion
|
|
1076
|
+
//#region src/composables/use-kimesh-app.d.ts
|
|
1077
|
+
/**
|
|
1078
|
+
* Get the Kimesh app context
|
|
1079
|
+
*
|
|
1080
|
+
* @example
|
|
1081
|
+
* ```ts
|
|
1082
|
+
* const { router, queryClient, $config } = useKimeshApp()
|
|
1083
|
+
* console.log($config.apiUrl)
|
|
1084
|
+
* ```
|
|
1085
|
+
*
|
|
1086
|
+
* @throws Error if called outside a Kimesh app
|
|
1087
|
+
*/
|
|
1088
|
+
declare function useKimeshApp(): KimeshAppContext;
|
|
1089
|
+
/**
|
|
1090
|
+
* Try to get the Kimesh app context without throwing
|
|
1091
|
+
*/
|
|
1092
|
+
declare function tryUseKimeshApp(): KimeshAppContext | undefined;
|
|
1093
|
+
//#endregion
|
|
1094
|
+
//#region src/composables/useState.d.ts
|
|
1095
|
+
declare const STATE_KEY_PREFIX = "$s_";
|
|
1096
|
+
/**
|
|
1097
|
+
* Get all state keys (without prefix).
|
|
1098
|
+
*/
|
|
1099
|
+
declare function getKmStateKeys(): string[];
|
|
1100
|
+
/**
|
|
1101
|
+
* Check if a state exists.
|
|
1102
|
+
*/
|
|
1103
|
+
declare function hasKmState(key: string): boolean;
|
|
1104
|
+
/**
|
|
1105
|
+
* Clear Kimesh state by key(s) or predicate.
|
|
1106
|
+
* Pass undefined to clear all state, a string for single key,
|
|
1107
|
+
* an array for multiple keys, or a predicate function.
|
|
1108
|
+
*/
|
|
1109
|
+
declare function clearKmState(keys?: string | string[] | ((key: string) => boolean)): void;
|
|
1110
|
+
/**
|
|
1111
|
+
* Get or create reactive state by key.
|
|
1112
|
+
*
|
|
1113
|
+
* @throws TypeError if key is not a non-empty string or init is not a function
|
|
1114
|
+
* @throws Error if _state is not initialized
|
|
1115
|
+
*/
|
|
1116
|
+
declare function useState<T>(key: string, init?: () => T | Ref<T>): Ref<T>;
|
|
1117
|
+
//#endregion
|
|
1118
|
+
//#region src/composables/use-navigation-middleware.d.ts
|
|
1119
|
+
/**
|
|
1120
|
+
* Navigation context for middleware
|
|
1121
|
+
*/
|
|
1122
|
+
interface NavigationContext {
|
|
1123
|
+
to: RouteLocationNormalized;
|
|
1124
|
+
from: RouteLocationNormalized;
|
|
1125
|
+
failure?: NavigationFailure;
|
|
1126
|
+
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Navigation error context
|
|
1129
|
+
*/
|
|
1130
|
+
interface NavigationErrorContext {
|
|
1131
|
+
error: Error;
|
|
1132
|
+
to: RouteLocationNormalized;
|
|
1133
|
+
from: RouteLocationNormalized;
|
|
1134
|
+
}
|
|
1135
|
+
type BeforeNavigationHandler = KimeshRuntimeHooks["navigate:before"];
|
|
1136
|
+
type AfterNavigationHandler = KimeshRuntimeHooks["navigate:after"];
|
|
1137
|
+
type ErrorNavigationHandler = KimeshRuntimeHooks["navigate:error"];
|
|
1138
|
+
/**
|
|
1139
|
+
* Options for useNavigationMiddleware
|
|
1140
|
+
*/
|
|
1141
|
+
interface NavigationMiddlewareOptions {
|
|
1142
|
+
/** Called before navigation */
|
|
1143
|
+
before?: BeforeNavigationHandler;
|
|
1144
|
+
/** Called after navigation */
|
|
1145
|
+
after?: AfterNavigationHandler;
|
|
1146
|
+
/** Called on navigation error */
|
|
1147
|
+
error?: ErrorNavigationHandler;
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* Register navigation middleware using the hook system
|
|
1151
|
+
*
|
|
1152
|
+
* @example
|
|
1153
|
+
* ```ts
|
|
1154
|
+
* // In a plugin or component setup
|
|
1155
|
+
* const { remove } = useNavigationMiddleware({
|
|
1156
|
+
* before: ({ to }) => {
|
|
1157
|
+
* if (!isAuthenticated() && to.meta.requiresAuth) {
|
|
1158
|
+
* return false // Cancel navigation
|
|
1159
|
+
* }
|
|
1160
|
+
* },
|
|
1161
|
+
* after: ({ to }) => {
|
|
1162
|
+
* analytics.trackPageView(to.path)
|
|
1163
|
+
* },
|
|
1164
|
+
* error: ({ error }) => {
|
|
1165
|
+
* console.error('Navigation failed:', error)
|
|
1166
|
+
* },
|
|
1167
|
+
* })
|
|
1168
|
+
*
|
|
1169
|
+
* // Cleanup when done
|
|
1170
|
+
* onUnmounted(() => remove())
|
|
1171
|
+
* ```
|
|
1172
|
+
*
|
|
1173
|
+
* @returns Object with remove function to cleanup hooks
|
|
1174
|
+
*/
|
|
1175
|
+
declare function useNavigationMiddleware(options: NavigationMiddlewareOptions): {
|
|
1176
|
+
remove: () => void;
|
|
1177
|
+
};
|
|
1178
|
+
/**
|
|
1179
|
+
* Create a navigation guard that runs before navigation
|
|
1180
|
+
*
|
|
1181
|
+
* @example
|
|
1182
|
+
* ```ts
|
|
1183
|
+
* // Auth guard plugin
|
|
1184
|
+
* export default defineKimeshRuntimePlugin({
|
|
1185
|
+
* name: 'auth-guard',
|
|
1186
|
+
* setup(app) {
|
|
1187
|
+
* app.runWithContext(() => {
|
|
1188
|
+
* useNavigationGuard(({ to }) => {
|
|
1189
|
+
* if (to.meta.requiresAuth && !isAuthenticated()) {
|
|
1190
|
+
* return false
|
|
1191
|
+
* }
|
|
1192
|
+
* })
|
|
1193
|
+
* })
|
|
1194
|
+
* }
|
|
1195
|
+
* })
|
|
1196
|
+
* ```
|
|
1197
|
+
*/
|
|
1198
|
+
declare function useNavigationGuard(guard: BeforeNavigationHandler): () => void;
|
|
1199
|
+
/**
|
|
1200
|
+
* Register a callback for after navigation
|
|
1201
|
+
*/
|
|
1202
|
+
declare function useAfterNavigation(callback: AfterNavigationHandler): () => void;
|
|
1203
|
+
//#endregion
|
|
1204
|
+
//#region src/middleware/types.d.ts
|
|
1205
|
+
/**
|
|
1206
|
+
* Navigation redirect configuration
|
|
1207
|
+
*/
|
|
1208
|
+
interface NavigationRedirect {
|
|
1209
|
+
/** Target path */
|
|
1210
|
+
path?: string;
|
|
1211
|
+
/** Target route name */
|
|
1212
|
+
name?: string;
|
|
1213
|
+
/** Route params */
|
|
1214
|
+
params?: Record<string, unknown>;
|
|
1215
|
+
/** Query parameters */
|
|
1216
|
+
query?: Record<string, unknown>;
|
|
1217
|
+
/** Replace current history entry instead of pushing */
|
|
1218
|
+
replace?: boolean;
|
|
1219
|
+
/** HTTP redirect code (for SSR) */
|
|
1220
|
+
redirectCode?: 301 | 302 | 303 | 307 | 308;
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Middleware execution result
|
|
1224
|
+
*/
|
|
1225
|
+
type MiddlewareResult = void | undefined | false | NavigationRedirect | Promise<void | undefined | false | NavigationRedirect>;
|
|
1226
|
+
/**
|
|
1227
|
+
* Middleware execution context
|
|
1228
|
+
*/
|
|
1229
|
+
interface MiddlewareContext {
|
|
1230
|
+
/** Current route being navigated to */
|
|
1231
|
+
to: RouteLocationNormalized;
|
|
1232
|
+
/** Previous route */
|
|
1233
|
+
from: RouteLocationNormalized;
|
|
1234
|
+
/** Vue Router instance */
|
|
1235
|
+
router: Router;
|
|
1236
|
+
/** Kimesh app context */
|
|
1237
|
+
app: KimeshAppContext;
|
|
1238
|
+
/** Custom data for sharing between middleware */
|
|
1239
|
+
data: Record<string, unknown>;
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* Middleware function signature
|
|
1243
|
+
*/
|
|
1244
|
+
type RouteMiddleware = (to: RouteLocationNormalized, from: RouteLocationNormalized, context: MiddlewareContext) => MiddlewareResult;
|
|
1245
|
+
/**
|
|
1246
|
+
* Typed middleware function with specific params type
|
|
1247
|
+
* Use this when you need typed params in inline middleware
|
|
1248
|
+
*
|
|
1249
|
+
* @example
|
|
1250
|
+
* ```ts
|
|
1251
|
+
* export const Route = createFileRoute('/users/:userId')({
|
|
1252
|
+
* middleware: ((to, from, ctx) => {
|
|
1253
|
+
* const userId = to.params.userId // typed!
|
|
1254
|
+
* }) as TypedRouteMiddleware<{ userId: string }>
|
|
1255
|
+
* })
|
|
1256
|
+
* ```
|
|
1257
|
+
*/
|
|
1258
|
+
type TypedRouteMiddleware<TParams extends Record<string, string> = Record<string, string>> = (to: RouteLocationNormalized & {
|
|
1259
|
+
params: TParams;
|
|
1260
|
+
}, from: RouteLocationNormalized, context: MiddlewareContext) => MiddlewareResult;
|
|
1261
|
+
/**
|
|
1262
|
+
* Object-style middleware definition
|
|
1263
|
+
*/
|
|
1264
|
+
interface MiddlewareDefinition {
|
|
1265
|
+
/** Optional middleware name */
|
|
1266
|
+
name?: string;
|
|
1267
|
+
/** Execution priority (higher = earlier) */
|
|
1268
|
+
priority?: number;
|
|
1269
|
+
/** Whether this middleware is global */
|
|
1270
|
+
global?: boolean;
|
|
1271
|
+
/** The middleware execution function */
|
|
1272
|
+
execute: RouteMiddleware;
|
|
1273
|
+
}
|
|
1274
|
+
/**
|
|
1275
|
+
* navigateTo options
|
|
1276
|
+
*/
|
|
1277
|
+
interface NavigateToOptions {
|
|
1278
|
+
/** Replace current history entry instead of pushing */
|
|
1279
|
+
replace?: boolean;
|
|
1280
|
+
/** HTTP redirect code (for SSR) */
|
|
1281
|
+
redirectCode?: 301 | 302 | 303 | 307 | 308;
|
|
1282
|
+
/** External URL (will use window.location) */
|
|
1283
|
+
external?: boolean;
|
|
1284
|
+
/** Query parameters to add */
|
|
1285
|
+
query?: Record<string, string | number>;
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Middleware registry entry
|
|
1289
|
+
*/
|
|
1290
|
+
interface MiddlewareRegistryEntry {
|
|
1291
|
+
name: string;
|
|
1292
|
+
fileName: string;
|
|
1293
|
+
isGlobal: boolean;
|
|
1294
|
+
priority: number;
|
|
1295
|
+
middleware: RouteMiddleware | MiddlewareDefinition;
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Generated middleware registry interface
|
|
1299
|
+
*/
|
|
1300
|
+
interface MiddlewareRegistry {
|
|
1301
|
+
globalMiddleware: RouteMiddleware[];
|
|
1302
|
+
namedMiddleware: Record<string, () => Promise<RouteMiddleware>>;
|
|
1303
|
+
middlewareNames: readonly string[];
|
|
1304
|
+
getGlobalMiddleware: () => RouteMiddleware[];
|
|
1305
|
+
getNamedMiddleware: (name: string) => (() => Promise<RouteMiddleware>) | undefined;
|
|
1306
|
+
hasMiddleware: (name: string) => boolean;
|
|
1307
|
+
}
|
|
1308
|
+
/**
|
|
1309
|
+
* Middleware option for route meta
|
|
1310
|
+
*/
|
|
1311
|
+
type MiddlewareOption = string | RouteMiddleware | Array<string | RouteMiddleware>;
|
|
1312
|
+
/**
|
|
1313
|
+
* Type augmentation for KimeshMiddlewareNames
|
|
1314
|
+
* This is augmented by generated types
|
|
1315
|
+
*/
|
|
1316
|
+
interface KimeshMiddlewareNames {}
|
|
1317
|
+
/**
|
|
1318
|
+
* Known middleware names (union of user-defined middleware)
|
|
1319
|
+
*/
|
|
1320
|
+
type KnownMiddleware = keyof KimeshMiddlewareNames extends never ? string : keyof KimeshMiddlewareNames;
|
|
1321
|
+
//#endregion
|
|
1322
|
+
//#region src/middleware/helpers.d.ts
|
|
1323
|
+
/**
|
|
1324
|
+
* Define a Kimesh middleware function
|
|
1325
|
+
*
|
|
1326
|
+
* @example Function-style
|
|
1327
|
+
* ```ts
|
|
1328
|
+
* export default defineKimeshMiddleware((to, from, ctx) => {
|
|
1329
|
+
* if (!isAuthenticated()) {
|
|
1330
|
+
* return navigateTo('/login')
|
|
1331
|
+
* }
|
|
1332
|
+
* })
|
|
1333
|
+
* ```
|
|
1334
|
+
*
|
|
1335
|
+
* @example Object-style
|
|
1336
|
+
* ```ts
|
|
1337
|
+
* export default defineKimeshMiddleware({
|
|
1338
|
+
* name: 'auth',
|
|
1339
|
+
* priority: 100,
|
|
1340
|
+
* execute(to, from, ctx) {
|
|
1341
|
+
* if (!isAuthenticated()) {
|
|
1342
|
+
* return abortNavigation('Not authenticated')
|
|
1343
|
+
* }
|
|
1344
|
+
* }
|
|
1345
|
+
* })
|
|
1346
|
+
* ```
|
|
1347
|
+
*/
|
|
1348
|
+
declare function defineKimeshMiddleware(middleware: RouteMiddleware): RouteMiddleware;
|
|
1349
|
+
declare function defineKimeshMiddleware(definition: MiddlewareDefinition): RouteMiddleware;
|
|
1350
|
+
/**
|
|
1351
|
+
* Navigate to a different route from middleware
|
|
1352
|
+
*
|
|
1353
|
+
* @example Simple path
|
|
1354
|
+
* ```ts
|
|
1355
|
+
* return navigateTo('/dashboard')
|
|
1356
|
+
* ```
|
|
1357
|
+
*
|
|
1358
|
+
* @example Route object
|
|
1359
|
+
* ```ts
|
|
1360
|
+
* return navigateTo({ name: 'user', params: { id: '123' } })
|
|
1361
|
+
* ```
|
|
1362
|
+
*
|
|
1363
|
+
* @example With options
|
|
1364
|
+
* ```ts
|
|
1365
|
+
* return navigateTo('/home', { replace: true })
|
|
1366
|
+
* ```
|
|
1367
|
+
*/
|
|
1368
|
+
declare function navigateTo(to: string | NavigationRedirect, options?: NavigateToOptions): NavigationRedirect;
|
|
1369
|
+
/**
|
|
1370
|
+
* Abort the current navigation
|
|
1371
|
+
*
|
|
1372
|
+
* @example
|
|
1373
|
+
* ```ts
|
|
1374
|
+
* return abortNavigation()
|
|
1375
|
+
* ```
|
|
1376
|
+
*
|
|
1377
|
+
* @example With reason
|
|
1378
|
+
* ```ts
|
|
1379
|
+
* return abortNavigation('Unauthorized access')
|
|
1380
|
+
* ```
|
|
1381
|
+
*
|
|
1382
|
+
* @example With error
|
|
1383
|
+
* ```ts
|
|
1384
|
+
* return abortNavigation(new Error('Custom error'))
|
|
1385
|
+
* ```
|
|
1386
|
+
*/
|
|
1387
|
+
declare function abortNavigation(reason?: string | Error): false;
|
|
1388
|
+
//#endregion
|
|
1389
|
+
//#region src/middleware/plugin.d.ts
|
|
1390
|
+
/**
|
|
1391
|
+
* @kimesh/router-runtime - Middleware Plugin
|
|
1392
|
+
*
|
|
1393
|
+
* Runtime plugin that integrates middleware execution with Vue Router.
|
|
1394
|
+
* Executes middleware in router.beforeEach guard.
|
|
1395
|
+
*/
|
|
1396
|
+
/**
|
|
1397
|
+
* Middleware runtime plugin
|
|
1398
|
+
* Registers with Vue Router and executes middleware on navigation
|
|
1399
|
+
*/
|
|
1400
|
+
declare const middlewarePlugin: KimeshRuntimePlugin<{
|
|
1401
|
+
middleware: {
|
|
1402
|
+
globalCount: number;
|
|
1403
|
+
namedCount: number;
|
|
1404
|
+
};
|
|
1405
|
+
}>;
|
|
1406
|
+
//#endregion
|
|
1407
|
+
//#region src/middleware/context.d.ts
|
|
1408
|
+
/**
|
|
1409
|
+
* Create middleware execution context
|
|
1410
|
+
*/
|
|
1411
|
+
declare function createMiddlewareContext(to: RouteLocationNormalized, from: RouteLocationNormalized, appContext: KimeshAppContext): MiddlewareContext;
|
|
1412
|
+
//#endregion
|
|
1413
|
+
//#region src/middleware/executor.d.ts
|
|
1414
|
+
/**
|
|
1415
|
+
* Execute a single middleware function
|
|
1416
|
+
*/
|
|
1417
|
+
declare function executeMiddleware(middleware: RouteMiddleware, context: MiddlewareContext, appContext: KimeshAppContext): Promise<void | false | NavigationRedirect>;
|
|
1418
|
+
/**
|
|
1419
|
+
* Execute a chain of middleware functions
|
|
1420
|
+
* Stops on first non-void result (redirect or abort)
|
|
1421
|
+
*/
|
|
1422
|
+
declare function executeMiddlewareChain(middlewares: RouteMiddleware[], context: MiddlewareContext, appContext: KimeshAppContext): Promise<void | false | NavigationRedirect>;
|
|
1423
|
+
/**
|
|
1424
|
+
* Create middleware executor with app context
|
|
1425
|
+
*/
|
|
1426
|
+
declare function createMiddlewareExecutor(appContext: KimeshAppContext): {
|
|
1427
|
+
/**
|
|
1428
|
+
* Execute a middleware function
|
|
1429
|
+
*/
|
|
1430
|
+
execute(middleware: RouteMiddleware, context: MiddlewareContext): Promise<void | false | NavigationRedirect>;
|
|
1431
|
+
/**
|
|
1432
|
+
* Execute a chain of middleware
|
|
1433
|
+
*/
|
|
1434
|
+
executeChain(middlewares: RouteMiddleware[], context: MiddlewareContext): Promise<void | false | NavigationRedirect>;
|
|
1435
|
+
};
|
|
1436
|
+
//#endregion
|
|
1437
|
+
export { LoaderGuardOptions as $, RoutePath as $t, RouteMiddleware as A, FullContext as At, getKmStateKeys as B, ParamValueOneOrMore as Bt, MiddlewareDefinition as C, CreateKimeshAppOptionsExtended as Ct, MiddlewareResult as D, CreateKimeshAppOptions as Dt, MiddlewareRegistryEntry as E, BeforeLoadContext as Et, useAfterNavigation as F, KimeshApp as Ft, RuntimeConfig as G, RouteHeadContext as Gt, useState as H, ParamValueZeroOrOne as Ht, useNavigationGuard as I, KimeshContext as It, useNavigate as J, RouteLocationRaw as Jt, useRuntimeConfig as K, RouteHeadFn as Kt, useNavigationMiddleware as L, LoaderContext as Lt, NavigationContext as M, InlineMiddlewareContext as Mt, NavigationErrorContext as N, InlineRouteMiddleware as Nt, NavigateToOptions as O, ExtractRouteParams as Ot, NavigationMiddlewareOptions as P, KIMESH_CONTEXT_KEY as Pt, useSearch as Q, RouteParamsRaw as Qt, STATE_KEY_PREFIX as R, LoaderFn as Rt, MiddlewareContext as S, defineRoute as St, MiddlewareRegistry as T, createKimeshApp as Tt, tryUseKimeshApp as U, RouteDefinition as Ut, hasKmState as V, ParamValueZeroOrMore as Vt, useKimeshApp as W, RouteHeadConfig as Wt, useReactiveParams as X, RouteNames as Xt, useParams as Y, RouteNamedMap as Yt, UseSearchReturn as Z, RouteParams as Zt, abortNavigation as _, getPluginName as _t, RouteRecordRaw$1 as a, KimeshRuntimePluginDefinition as an, KmOutlet as at, KimeshMiddlewareNames as b, useKimeshContext as bt, onBeforeRouteUpdate as c, NavigationAfterHookContext as cn, queryPlugin as ct, useRouter$1 as d, RuntimeConfigPublic as dn, applyPlugins as dt, RouteRecordInfo as en, createLoaderGuard as et, createMiddlewareExecutor as f, applyPluginsWithParallel as ft, middlewarePlugin as g, getPluginMeta as gt, createMiddlewareContext as h, getPluginHooks as ht, RouteLocationNormalizedLoaded$1 as i, KimeshRuntimePlugin as in, KmLinkProps as it, TypedRouteMiddleware as j, HasParams as jt, NavigationRedirect as k, FileRouteOptions as kt, useLink as l, NavigationErrorHookContext as ln, routerPlugin as lt, executeMiddlewareChain as m, defineKimeshRuntimePlugin as mt, NavigationHookAfter as n, KimeshAppContext as nn, KmDeferred as nt, Router$1 as o, KimeshRuntimePluginMeta as on, QueryPluginOptions as ot, executeMiddleware as p, KIMESH_PLUGIN_INDICATOR as pt, NavigateOptions as q, RouteInfoByName as qt, RouteLocationNormalized$1 as r, KimeshRuntimeHooks as rn, KmLink as rt, onBeforeRouteLeave as s, KimeshRuntimePluginResult as sn, getCorePlugins as st, NavigationGuard as t, SearchSchema as tn, installLoaderGuard as tt, useRoute$1 as u, NavigationHookContext as un, applyPlugin as ut, defineKimeshMiddleware as v, isKimeshRuntimePlugin as vt, MiddlewareOption as w, KIMESH_APP_CONTEXT_KEY as wt, KnownMiddleware as x, createFileRoute as xt, navigateTo as y, defineContext as yt, clearKmState as z, ParamValue as zt };
|