@kimesh/router-runtime 0.2.24 → 0.2.25
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-Bi0AaYQy.d.mts → index-xv5oFInR.d.mts} +93 -28
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/middleware/index.d.mts +2 -2
- package/dist/middleware/index.mjs +1 -1
- package/dist/middleware/plugin.d.mts +1 -1
- package/dist/{middleware-DdlzhfiB.mjs → middleware-DvCiATAB.mjs} +6 -19
- package/package.json +1 -1
|
@@ -241,6 +241,44 @@ type RouteParams<T extends string> = T extends keyof RouteNamedMap ? RouteNamedM
|
|
|
241
241
|
type RoutePath<T extends string> = T extends keyof RouteNamedMap ? RouteNamedMap[T] extends RouteRecordInfo<any, infer P, any, any, any> ? P : string : string;
|
|
242
242
|
/** Check if route has params */
|
|
243
243
|
type HasParams<T extends string> = T extends keyof RouteNamedMap ? keyof RouteParams<T> extends never ? false : true : boolean;
|
|
244
|
+
/**
|
|
245
|
+
* Type-safe navigation redirect for static routes (no params)
|
|
246
|
+
*/
|
|
247
|
+
interface TypedRedirectStatic<T extends RouteNames = RouteNames> {
|
|
248
|
+
/** Target path (type-safe) */
|
|
249
|
+
path: HasParams<T> extends false ? T : never;
|
|
250
|
+
/** Query parameters */
|
|
251
|
+
query?: Record<string, string | number | undefined>;
|
|
252
|
+
/** Replace current history entry instead of pushing */
|
|
253
|
+
replace?: boolean;
|
|
254
|
+
/** HTTP redirect code (for SSR) */
|
|
255
|
+
redirectCode?: 301 | 302 | 303 | 307 | 308;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Type-safe navigation redirect for dynamic routes (with params)
|
|
259
|
+
*/
|
|
260
|
+
interface TypedRedirectDynamic<T extends RouteNames = RouteNames> {
|
|
261
|
+
/** Target path (type-safe) */
|
|
262
|
+
path: HasParams<T> extends true ? T : never;
|
|
263
|
+
/** Route params (required for dynamic routes) */
|
|
264
|
+
params: RouteParamsRaw<T>;
|
|
265
|
+
/** Query parameters */
|
|
266
|
+
query?: Record<string, string | number | undefined>;
|
|
267
|
+
/** Replace current history entry instead of pushing */
|
|
268
|
+
replace?: boolean;
|
|
269
|
+
/** HTTP redirect code (for SSR) */
|
|
270
|
+
redirectCode?: 301 | 302 | 303 | 307 | 308;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Type-safe navigation redirect - union of static and dynamic
|
|
274
|
+
*/
|
|
275
|
+
type TypedNavigationRedirect = TypedRedirectStatic<RouteNames> | TypedRedirectDynamic<RouteNames> | {
|
|
276
|
+
path: string;
|
|
277
|
+
params?: Record<string, string | number>;
|
|
278
|
+
query?: Record<string, unknown>;
|
|
279
|
+
replace?: boolean;
|
|
280
|
+
redirectCode?: 301 | 302 | 303 | 307 | 308;
|
|
281
|
+
};
|
|
244
282
|
/**
|
|
245
283
|
* Options for creating a Kimesh app
|
|
246
284
|
*/
|
|
@@ -393,16 +431,21 @@ interface InlineMiddlewareContext {
|
|
|
393
431
|
/**
|
|
394
432
|
* Inline route middleware with typed params
|
|
395
433
|
* Used in createFileRoute for automatic param inference
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* ```ts
|
|
437
|
+
* middleware: (to, from, ctx) => {
|
|
438
|
+
* if (!isAuthenticated()) {
|
|
439
|
+
* return { path: '/login' } // Type-safe redirect
|
|
440
|
+
* }
|
|
441
|
+
* // Or use navigateTo for more options
|
|
442
|
+
* return navigateTo('/dashboard', { replace: true })
|
|
443
|
+
* }
|
|
444
|
+
* ```
|
|
396
445
|
*/
|
|
397
446
|
type InlineRouteMiddleware<TParams = Record<string, string>> = (to: RouteLocationNormalized & {
|
|
398
447
|
params: TParams;
|
|
399
|
-
}, from: RouteLocationNormalized, context: InlineMiddlewareContext) => void | undefined | false |
|
|
400
|
-
path?: string;
|
|
401
|
-
name?: string;
|
|
402
|
-
} | Promise<void | undefined | false | {
|
|
403
|
-
path?: string;
|
|
404
|
-
name?: string;
|
|
405
|
-
}>;
|
|
448
|
+
}, from: RouteLocationNormalized, context: InlineMiddlewareContext) => void | undefined | false | TypedNavigationRedirect | Promise<void | undefined | false | TypedNavigationRedirect>;
|
|
406
449
|
/**
|
|
407
450
|
* File route options
|
|
408
451
|
*/
|
|
@@ -1463,19 +1506,6 @@ interface MiddlewareDefinition {
|
|
|
1463
1506
|
/** The middleware execution function */
|
|
1464
1507
|
execute: RouteMiddleware;
|
|
1465
1508
|
}
|
|
1466
|
-
/**
|
|
1467
|
-
* navigateTo options
|
|
1468
|
-
*/
|
|
1469
|
-
interface NavigateToOptions {
|
|
1470
|
-
/** Replace current history entry instead of pushing */
|
|
1471
|
-
replace?: boolean;
|
|
1472
|
-
/** HTTP redirect code (for SSR) */
|
|
1473
|
-
redirectCode?: 301 | 302 | 303 | 307 | 308;
|
|
1474
|
-
/** External URL (will use window.location) */
|
|
1475
|
-
external?: boolean;
|
|
1476
|
-
/** Query parameters to add */
|
|
1477
|
-
query?: Record<string, string | number>;
|
|
1478
|
-
}
|
|
1479
1509
|
/**
|
|
1480
1510
|
* Middleware registry entry
|
|
1481
1511
|
*/
|
|
@@ -1540,24 +1570,59 @@ type KnownMiddleware = keyof KimeshMiddlewareNames extends never ? string : keyo
|
|
|
1540
1570
|
declare function defineKimeshMiddleware(middleware: RouteMiddleware): RouteMiddleware;
|
|
1541
1571
|
declare function defineKimeshMiddleware(definition: MiddlewareDefinition): RouteMiddleware;
|
|
1542
1572
|
/**
|
|
1543
|
-
*
|
|
1573
|
+
* Options for type-safe route navigation
|
|
1574
|
+
*/
|
|
1575
|
+
interface NavigateToOptions {
|
|
1576
|
+
/** Replace current history entry instead of pushing */
|
|
1577
|
+
replace?: boolean;
|
|
1578
|
+
/** HTTP redirect code (for SSR) */
|
|
1579
|
+
redirectCode?: 301 | 302 | 303 | 307 | 308;
|
|
1580
|
+
/** External URL (will use window.location) */
|
|
1581
|
+
external?: boolean;
|
|
1582
|
+
/** Query parameters to add */
|
|
1583
|
+
query?: Record<string, string | number | undefined>;
|
|
1584
|
+
/** Route params for dynamic routes */
|
|
1585
|
+
params?: Record<string, string | number>;
|
|
1586
|
+
}
|
|
1587
|
+
/**
|
|
1588
|
+
* Type-safe navigation options - requires params for dynamic routes
|
|
1589
|
+
*/
|
|
1590
|
+
type TypedNavigateToOptions<T extends string> = HasParams<T> extends true ? NavigateToOptions & {
|
|
1591
|
+
params: RouteParamsRaw<T>;
|
|
1592
|
+
} : NavigateToOptions & {
|
|
1593
|
+
params?: undefined;
|
|
1594
|
+
};
|
|
1595
|
+
/**
|
|
1596
|
+
* Navigate to a route with type-safe params
|
|
1544
1597
|
*
|
|
1545
|
-
* @example
|
|
1598
|
+
* @example Static route
|
|
1546
1599
|
* ```ts
|
|
1547
1600
|
* return navigateTo('/dashboard')
|
|
1601
|
+
* return navigateTo('/login', { replace: true })
|
|
1602
|
+
* ```
|
|
1603
|
+
*
|
|
1604
|
+
* @example Dynamic route with params
|
|
1605
|
+
* ```ts
|
|
1606
|
+
* return navigateTo('/users/:userId', { params: { userId: '123' } })
|
|
1607
|
+
* return navigateTo('/posts/:postId', { params: { postId: 456 }, replace: true })
|
|
1548
1608
|
* ```
|
|
1549
1609
|
*
|
|
1550
|
-
* @example
|
|
1610
|
+
* @example With query params
|
|
1551
1611
|
* ```ts
|
|
1552
|
-
* return navigateTo(
|
|
1612
|
+
* return navigateTo('/search', { query: { q: 'hello' } })
|
|
1553
1613
|
* ```
|
|
1614
|
+
*/
|
|
1615
|
+
declare function navigateTo<T extends RouteNames>(to: T, options?: TypedNavigateToOptions<T>): NavigationRedirect;
|
|
1616
|
+
/**
|
|
1617
|
+
* Navigate using a NavigationRedirect object
|
|
1554
1618
|
*
|
|
1555
|
-
* @example
|
|
1619
|
+
* @example
|
|
1556
1620
|
* ```ts
|
|
1557
|
-
* return navigateTo('/
|
|
1621
|
+
* return navigateTo({ path: '/dashboard', query: { tab: 'settings' } })
|
|
1622
|
+
* return navigateTo({ name: 'user-profile', params: { id: '123' } })
|
|
1558
1623
|
* ```
|
|
1559
1624
|
*/
|
|
1560
|
-
declare function navigateTo(to:
|
|
1625
|
+
declare function navigateTo(to: NavigationRedirect, options?: NavigateToOptions): NavigationRedirect;
|
|
1561
1626
|
/**
|
|
1562
1627
|
* Abort the current navigation
|
|
1563
1628
|
*
|
|
@@ -1651,4 +1716,4 @@ declare function createMiddlewareExecutor(appContext: KimeshAppContext): {
|
|
|
1651
1716
|
executeChain(middlewares: RouteMiddleware[], context: MiddlewareContext): Promise<void | false | NavigationRedirect>;
|
|
1652
1717
|
};
|
|
1653
1718
|
//#endregion
|
|
1654
|
-
export {
|
|
1719
|
+
export { getKmStateKeys as $, FullContext as $t, MiddlewareRegistryEntry as A, KimeshAppContext as An, applyPlugin as At, isLayoutRouteMeta as B, useKimeshContext as Bt, navigateTo as C, RouteParamsRaw as Cn, createHeadPlugin as Ct, MiddlewareDefinition as D, TypedNavigationRedirect as Dn, getCorePlugins as Dt, MiddlewareContext as E, SearchSchema as En, QueryPluginOptions as Et, LayoutLoaderData as F, KimeshRuntimePluginResult as Fn, getPluginHooks as Ft, NavigationContext as G, createKimeshApp as Gt, useLoaderData as H, defineRoute as Ht, LayoutRouteMeta as I, NavigationAfterHookContext as In, getPluginMeta as It, useAfterNavigation as J, BeforeLoadContextFull as Jt, NavigationErrorContext as K, AugmentedContext as Kt, LoaderDataKey as L, NavigationErrorHookContext as Ln, getPluginName as Lt, NavigationRedirect as M, KimeshRuntimePlugin as Mn, applyPluginsWithParallel as Mt, RouteMiddleware as N, KimeshRuntimePluginDefinition as Nn, KIMESH_PLUGIN_INDICATOR as Nt, MiddlewareOption as O, TypedRedirectDynamic as On, queryPlugin as Ot, TypedRouteMiddleware as P, KimeshRuntimePluginMeta as Pn, defineKimeshRuntimePlugin as Pt, clearKmState as Q, FileRouteOptions as Qt, UseMatchLoaderDataOptions as R, NavigationHookContext as Rn, isKimeshRuntimePlugin as Rt, defineKimeshMiddleware as S, RouteParams as Sn, collectRouteHeads as St, KnownMiddleware as T, RouteRecordInfo as Tn, mergeHeadConfigs as Tt, useMatchLoaderData as U, CreateKimeshAppOptionsExtended as Ut, useLayoutData as V, createFileRoute as Vt, useRouteLoaderData as W, KIMESH_APP_CONTEXT_KEY as Wt, useNavigationMiddleware as X, CreateKimeshAppOptions as Xt, useNavigationGuard as Y, BeforeLoadFn as Yt, STATE_KEY_PREFIX as Z, ExtractRouteParams as Zt, createMiddlewarePlugin as _, RouteHeadFn as _n, KmLinkProps as _t, RouteRecordRaw$1 as a, KimeshContext as an, useRuntimeConfig as at, TypedNavigateToOptions as b, RouteNamedMap as bn, applyHeadConfigNative as bt, onBeforeRouteUpdate as c, ParamValue as cn, useParams as ct, useRouter$1 as d, ParamValueZeroOrOne as dn, useSearch as dt, HasParams as en, hasKmState as et, createMiddlewareExecutor as f, PendingConfig as fn, LoaderGuardOptions as ft, MiddlewarePluginOptions as g, RouteHeadContext as gn, KmLink as gt, createMiddlewareContext as h, RouteHeadConfig as hn, KmDeferred as ht, RouteLocationNormalizedLoaded$1 as i, KimeshApp as in, RuntimeConfig as it, MiddlewareResult as j, KimeshRuntimeHooks as jn, applyPlugins as jt, MiddlewareRegistry as k, TypedRedirectStatic as kn, routerPlugin as kt, useLink as l, ParamValueOneOrMore as ln, useReactiveParams as lt, executeMiddlewareChain as m, RouteDefinition as mn, installLoaderGuard as mt, NavigationHookAfter as n, InlineRouteMiddleware as nn, tryUseKimeshApp as nt, Router$1 as o, LoaderContext as on, NavigateOptions as ot, executeMiddleware as p, RouteContext as pn, createLoaderGuard as pt, NavigationMiddlewareOptions as q, BeforeLoadContext as qt, RouteLocationNormalized$1 as r, KIMESH_CONTEXT_KEY as rn, useKimeshApp as rt, onBeforeRouteLeave as s, LoaderFn as sn, useNavigate as st, NavigationGuard as t, InlineMiddlewareContext as tn, useState as tt, useRoute$1 as u, ParamValueZeroOrMore as un, UseSearchReturn as ut, middlewarePlugin as v, RouteInfoByName as vn, KmOutlet as vt, KimeshMiddlewareNames as w, RoutePath as wn, mergeAllRouteHeads as wt, abortNavigation as x, RouteNames as xn, applyTitleTemplate as xt, NavigateToOptions as y, RouteLocationRaw as yn, HeadPluginOptions as yt, createLoaderDataKey as z, RuntimeConfigPublic as zn, defineContext as zt };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { AugmentedContext, BeforeLoadContext, BeforeLoadContextFull, BeforeLoadFn, CreateKimeshAppOptions, CreateKimeshAppOptionsExtended, ExtractRouteParams, FileRouteOptions, FullContext, HasParams, HeadPluginOptions, InlineMiddlewareContext, InlineRouteMiddleware, KIMESH_APP_CONTEXT_KEY, KIMESH_CONTEXT_KEY, KIMESH_PLUGIN_INDICATOR, KimeshApp, KimeshAppContext, KimeshContext, KimeshMiddlewareNames, KimeshRuntimeHooks, KimeshRuntimePlugin, KimeshRuntimePluginDefinition, KimeshRuntimePluginMeta, KimeshRuntimePluginResult, KmDeferred, KmLink, KmLinkProps, KmOutlet, KnownMiddleware, LayoutLoaderData, LayoutRouteMeta, LoaderContext, LoaderDataKey, LoaderFn, LoaderGuardOptions, MiddlewareContext, MiddlewareDefinition, MiddlewareOption, MiddlewarePluginOptions, MiddlewareResult, NavigateOptions, NavigateToOptions, NavigationAfterHookContext, NavigationContext, NavigationErrorContext, NavigationErrorHookContext, NavigationGuard, NavigationHookAfter, NavigationHookContext, NavigationMiddlewareOptions, NavigationRedirect, ParamValue, ParamValueOneOrMore, ParamValueZeroOrMore, ParamValueZeroOrOne, PendingConfig, QueryPluginOptions, RouteContext, RouteDefinition, RouteHeadConfig, RouteHeadContext, RouteHeadFn, RouteInfoByName, RouteLocationNormalized, RouteLocationNormalizedLoaded, RouteLocationRaw, RouteMiddleware, RouteNamedMap, RouteNames, RouteParams, RouteParamsRaw, RoutePath, RouteRecordInfo, RouteRecordRaw, Router, RuntimeConfig, RuntimeConfigPublic, STATE_KEY_PREFIX, SearchSchema, TypedRouteMiddleware, UseMatchLoaderDataOptions, UseSearchReturn, abortNavigation, applyHeadConfigNative, applyPlugin, applyPlugins, applyPluginsWithParallel, applyTitleTemplate, clearKmState, collectRouteHeads, createFileRoute, createHeadPlugin, createKimeshApp, createLoaderDataKey, createLoaderGuard, createMiddlewareContext, createMiddlewareExecutor, createMiddlewarePlugin, defineContext, defineKimeshMiddleware, defineKimeshRuntimePlugin, defineRoute, getCorePlugins, getKmStateKeys, getPluginHooks, getPluginMeta, getPluginName, hasKmState, installLoaderGuard, isKimeshRuntimePlugin, isLayoutRouteMeta, mergeAllRouteHeads, mergeHeadConfigs, middlewarePlugin, navigateTo, onBeforeRouteLeave, onBeforeRouteUpdate, queryPlugin, routerPlugin, tryUseKimeshApp, useAfterNavigation, useKimeshApp, useKimeshContext, useLayoutData, useLink, useLoaderData, useMatchLoaderData, useNavigate, useNavigationGuard, useNavigationMiddleware, useParams, useReactiveParams, useRoute, useRouteLoaderData, useRouter, useRuntimeConfig, useSearch, useState };
|
|
1
|
+
import { $ as getKmStateKeys, $t as FullContext, An as KimeshAppContext, At as applyPlugin, B as isLayoutRouteMeta, Bt as useKimeshContext, C as navigateTo, Cn as RouteParamsRaw, Ct as createHeadPlugin, D as MiddlewareDefinition, Dn as TypedNavigationRedirect, Dt as getCorePlugins, E as MiddlewareContext, En as SearchSchema, Et as QueryPluginOptions, F as LayoutLoaderData, Fn as KimeshRuntimePluginResult, Ft as getPluginHooks, G as NavigationContext, Gt as createKimeshApp, H as useLoaderData, Ht as defineRoute, I as LayoutRouteMeta, In as NavigationAfterHookContext, It as getPluginMeta, J as useAfterNavigation, Jt as BeforeLoadContextFull, K as NavigationErrorContext, Kt as AugmentedContext, L as LoaderDataKey, Ln as NavigationErrorHookContext, Lt as getPluginName, M as NavigationRedirect, Mn as KimeshRuntimePlugin, Mt as applyPluginsWithParallel, N as RouteMiddleware, Nn as KimeshRuntimePluginDefinition, Nt as KIMESH_PLUGIN_INDICATOR, O as MiddlewareOption, On as TypedRedirectDynamic, Ot as queryPlugin, P as TypedRouteMiddleware, Pn as KimeshRuntimePluginMeta, Pt as defineKimeshRuntimePlugin, Q as clearKmState, Qt as FileRouteOptions, R as UseMatchLoaderDataOptions, Rn as NavigationHookContext, Rt as isKimeshRuntimePlugin, S as defineKimeshMiddleware, Sn as RouteParams, St as collectRouteHeads, T as KnownMiddleware, Tn as RouteRecordInfo, Tt as mergeHeadConfigs, U as useMatchLoaderData, Ut as CreateKimeshAppOptionsExtended, V as useLayoutData, Vt as createFileRoute, W as useRouteLoaderData, Wt as KIMESH_APP_CONTEXT_KEY, X as useNavigationMiddleware, Xt as CreateKimeshAppOptions, Y as useNavigationGuard, Yt as BeforeLoadFn, Z as STATE_KEY_PREFIX, Zt as ExtractRouteParams, _ as createMiddlewarePlugin, _n as RouteHeadFn, _t as KmLinkProps, a as RouteRecordRaw, an as KimeshContext, at as useRuntimeConfig, bn as RouteNamedMap, bt as applyHeadConfigNative, c as onBeforeRouteUpdate, cn as ParamValue, ct as useParams, d as useRouter, dn as ParamValueZeroOrOne, dt as useSearch, en as HasParams, et as hasKmState, f as createMiddlewareExecutor, fn as PendingConfig, ft as LoaderGuardOptions, g as MiddlewarePluginOptions, gn as RouteHeadContext, gt as KmLink, h as createMiddlewareContext, hn as RouteHeadConfig, ht as KmDeferred, i as RouteLocationNormalizedLoaded, in as KimeshApp, it as RuntimeConfig, j as MiddlewareResult, jn as KimeshRuntimeHooks, jt as applyPlugins, kn as TypedRedirectStatic, kt as routerPlugin, l as useLink, ln as ParamValueOneOrMore, lt as useReactiveParams, mn as RouteDefinition, mt as installLoaderGuard, n as NavigationHookAfter, nn as InlineRouteMiddleware, nt as tryUseKimeshApp, o as Router, on as LoaderContext, ot as NavigateOptions, pn as RouteContext, pt as createLoaderGuard, q as NavigationMiddlewareOptions, qt as BeforeLoadContext, r as RouteLocationNormalized, rn as KIMESH_CONTEXT_KEY, rt as useKimeshApp, s as onBeforeRouteLeave, sn as LoaderFn, st as useNavigate, t as NavigationGuard, tn as InlineMiddlewareContext, tt as useState, u as useRoute, un as ParamValueZeroOrMore, ut as UseSearchReturn, v as middlewarePlugin, vn as RouteInfoByName, vt as KmOutlet, w as KimeshMiddlewareNames, wn as RoutePath, wt as mergeAllRouteHeads, x as abortNavigation, xn as RouteNames, xt as applyTitleTemplate, y as NavigateToOptions, yn as RouteLocationRaw, yt as HeadPluginOptions, z as createLoaderDataKey, zn as RuntimeConfigPublic, zt as defineContext } from "./index-xv5oFInR.mjs";
|
|
2
|
+
export { AugmentedContext, BeforeLoadContext, BeforeLoadContextFull, BeforeLoadFn, CreateKimeshAppOptions, CreateKimeshAppOptionsExtended, ExtractRouteParams, FileRouteOptions, FullContext, HasParams, HeadPluginOptions, InlineMiddlewareContext, InlineRouteMiddleware, KIMESH_APP_CONTEXT_KEY, KIMESH_CONTEXT_KEY, KIMESH_PLUGIN_INDICATOR, KimeshApp, KimeshAppContext, KimeshContext, KimeshMiddlewareNames, KimeshRuntimeHooks, KimeshRuntimePlugin, KimeshRuntimePluginDefinition, KimeshRuntimePluginMeta, KimeshRuntimePluginResult, KmDeferred, KmLink, KmLinkProps, KmOutlet, KnownMiddleware, LayoutLoaderData, LayoutRouteMeta, LoaderContext, LoaderDataKey, LoaderFn, LoaderGuardOptions, MiddlewareContext, MiddlewareDefinition, MiddlewareOption, MiddlewarePluginOptions, MiddlewareResult, NavigateOptions, NavigateToOptions, NavigationAfterHookContext, NavigationContext, NavigationErrorContext, NavigationErrorHookContext, NavigationGuard, NavigationHookAfter, NavigationHookContext, NavigationMiddlewareOptions, NavigationRedirect, ParamValue, ParamValueOneOrMore, ParamValueZeroOrMore, ParamValueZeroOrOne, PendingConfig, QueryPluginOptions, RouteContext, RouteDefinition, RouteHeadConfig, RouteHeadContext, RouteHeadFn, RouteInfoByName, RouteLocationNormalized, RouteLocationNormalizedLoaded, RouteLocationRaw, RouteMiddleware, RouteNamedMap, RouteNames, RouteParams, RouteParamsRaw, RoutePath, RouteRecordInfo, RouteRecordRaw, Router, RuntimeConfig, RuntimeConfigPublic, STATE_KEY_PREFIX, SearchSchema, TypedNavigationRedirect, TypedRedirectDynamic, TypedRedirectStatic, TypedRouteMiddleware, UseMatchLoaderDataOptions, UseSearchReturn, abortNavigation, applyHeadConfigNative, applyPlugin, applyPlugins, applyPluginsWithParallel, applyTitleTemplate, clearKmState, collectRouteHeads, createFileRoute, createHeadPlugin, createKimeshApp, createLoaderDataKey, createLoaderGuard, createMiddlewareContext, createMiddlewareExecutor, createMiddlewarePlugin, defineContext, defineKimeshMiddleware, defineKimeshRuntimePlugin, defineRoute, getCorePlugins, getKmStateKeys, getPluginHooks, getPluginMeta, getPluginName, hasKmState, installLoaderGuard, isKimeshRuntimePlugin, isLayoutRouteMeta, mergeAllRouteHeads, mergeHeadConfigs, middlewarePlugin, navigateTo, onBeforeRouteLeave, onBeforeRouteUpdate, queryPlugin, routerPlugin, tryUseKimeshApp, useAfterNavigation, useKimeshApp, useKimeshContext, useLayoutData, useLink, useLoaderData, useMatchLoaderData, useNavigate, useNavigationGuard, useNavigationMiddleware, useParams, useReactiveParams, useRoute, useRouteLoaderData, useRouter, useRuntimeConfig, useSearch, useState };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as KIMESH_PLUGIN_INDICATOR, c as getPluginMeta, i as createMiddlewareContext, l as getPluginName, n as middlewarePlugin, o as defineKimeshRuntimePlugin, s as getPluginHooks, t as createMiddlewarePlugin, u as isKimeshRuntimePlugin } from "./plugin-0r5-meph.mjs";
|
|
2
|
-
import { a as defineKimeshMiddleware, i as abortNavigation, o as navigateTo, t as createMiddlewareExecutor } from "./middleware-
|
|
2
|
+
import { a as defineKimeshMiddleware, i as abortNavigation, o as navigateTo, t as createMiddlewareExecutor } from "./middleware-DvCiATAB.mjs";
|
|
3
3
|
import { KeepAlive, Suspense, Transition, computed, createApp, defineComponent, h, inject, isRef, nextTick, onErrorCaptured, reactive, ref, toRef } from "vue";
|
|
4
4
|
import { RouterLink, RouterView, createRouter, createWebHashHistory, createWebHistory, onBeforeRouteLeave, onBeforeRouteUpdate, useLink, useRoute, useRoute as useRoute$1, useRouter, useRouter as useRouter$1 } from "vue-router";
|
|
5
5
|
import { QueryClient, VueQueryPlugin } from "@tanstack/vue-query";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { KimeshMiddlewareNames, KnownMiddleware, MiddlewareContext, MiddlewareDefinition, MiddlewareOption, MiddlewarePluginOptions, MiddlewareRegistry, MiddlewareRegistryEntry, MiddlewareResult, NavigateToOptions, NavigationRedirect, RouteMiddleware, TypedRouteMiddleware, abortNavigation, createMiddlewareContext, createMiddlewareExecutor, createMiddlewarePlugin, defineKimeshMiddleware, executeMiddleware, executeMiddlewareChain, middlewarePlugin, navigateTo };
|
|
1
|
+
import { A as MiddlewareRegistryEntry, C as navigateTo, D as MiddlewareDefinition, E as MiddlewareContext, M as NavigationRedirect, N as RouteMiddleware, O as MiddlewareOption, P as TypedRouteMiddleware, S as defineKimeshMiddleware, T as KnownMiddleware, _ as createMiddlewarePlugin, b as TypedNavigateToOptions, f as createMiddlewareExecutor, g as MiddlewarePluginOptions, h as createMiddlewareContext, j as MiddlewareResult, k as MiddlewareRegistry, m as executeMiddlewareChain, p as executeMiddleware, v as middlewarePlugin, w as KimeshMiddlewareNames, x as abortNavigation, y as NavigateToOptions } from "../index-xv5oFInR.mjs";
|
|
2
|
+
export { KimeshMiddlewareNames, KnownMiddleware, MiddlewareContext, MiddlewareDefinition, MiddlewareOption, MiddlewarePluginOptions, MiddlewareRegistry, MiddlewareRegistryEntry, MiddlewareResult, NavigateToOptions, NavigationRedirect, RouteMiddleware, TypedNavigateToOptions, TypedRouteMiddleware, abortNavigation, createMiddlewareContext, createMiddlewareExecutor, createMiddlewarePlugin, defineKimeshMiddleware, executeMiddleware, executeMiddlewareChain, middlewarePlugin, navigateTo };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { i as createMiddlewareContext, n as middlewarePlugin, t as createMiddlewarePlugin } from "../plugin-0r5-meph.mjs";
|
|
2
|
-
import { a as defineKimeshMiddleware, i as abortNavigation, n as executeMiddleware, o as navigateTo, r as executeMiddlewareChain, t as createMiddlewareExecutor } from "../middleware-
|
|
2
|
+
import { a as defineKimeshMiddleware, i as abortNavigation, n as executeMiddleware, o as navigateTo, r as executeMiddlewareChain, t as createMiddlewareExecutor } from "../middleware-DvCiATAB.mjs";
|
|
3
3
|
|
|
4
4
|
export { abortNavigation, createMiddlewareContext, createMiddlewareExecutor, createMiddlewarePlugin, defineKimeshMiddleware, executeMiddleware, executeMiddlewareChain, middlewarePlugin, navigateTo };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as createMiddlewarePlugin, g as MiddlewarePluginOptions, v as middlewarePlugin } from "../index-
|
|
1
|
+
import { _ as createMiddlewarePlugin, g as MiddlewarePluginOptions, v as middlewarePlugin } from "../index-xv5oFInR.mjs";
|
|
2
2
|
export { MiddlewarePluginOptions, createMiddlewarePlugin, middlewarePlugin as default, middlewarePlugin };
|
|
@@ -4,28 +4,15 @@ function defineKimeshMiddleware(fnOrDefinition) {
|
|
|
4
4
|
if (typeof fnOrDefinition === "object" && fnOrDefinition !== null && "execute" in fnOrDefinition) return fnOrDefinition.execute;
|
|
5
5
|
throw new Error("[Kimesh] Invalid middleware definition. Expected function or object with execute method.");
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
* Navigate to a different route from middleware
|
|
9
|
-
*
|
|
10
|
-
* @example Simple path
|
|
11
|
-
* ```ts
|
|
12
|
-
* return navigateTo('/dashboard')
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* @example Route object
|
|
16
|
-
* ```ts
|
|
17
|
-
* return navigateTo({ name: 'user', params: { id: '123' } })
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @example With options
|
|
21
|
-
* ```ts
|
|
22
|
-
* return navigateTo('/home', { replace: true })
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
7
|
function navigateTo(to, options = {}) {
|
|
26
8
|
if (typeof to === "string") {
|
|
9
|
+
let resolvedPath = to;
|
|
10
|
+
if (options.params) for (const [key, value] of Object.entries(options.params)) {
|
|
11
|
+
resolvedPath = resolvedPath.replace(`:${key}`, String(value));
|
|
12
|
+
resolvedPath = resolvedPath.replace(`$${key}`, String(value));
|
|
13
|
+
}
|
|
27
14
|
const result = {
|
|
28
|
-
path:
|
|
15
|
+
path: resolvedPath,
|
|
29
16
|
replace: options.replace ?? false,
|
|
30
17
|
redirectCode: options.redirectCode
|
|
31
18
|
};
|