@kimesh/router-runtime 0.2.10 → 0.2.11-nightly.20260127015259
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 → index-9xJk3v3Z.d.mts} +55 -30
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +9 -9
- package/dist/middleware/index.d.mts +2 -2
- package/dist/middleware/index.mjs +2 -2
- package/dist/middleware/plugin.d.mts +2 -2
- package/dist/middleware/plugin.mjs +2 -2
- package/dist/{plugin-DsScck9c.mjs → plugin-BfxCqV0B.mjs} +53 -39
- package/package.json +19 -19
|
@@ -13,7 +13,7 @@ interface KimeshRuntimePluginMeta {
|
|
|
13
13
|
/** Plugin name for debugging */
|
|
14
14
|
name?: string;
|
|
15
15
|
/** Execution order: pre runs first, post runs last */
|
|
16
|
-
enforce?:
|
|
16
|
+
enforce?: 'pre' | 'default' | 'post';
|
|
17
17
|
/** Numeric order for fine-grained control */
|
|
18
18
|
order?: number;
|
|
19
19
|
/** Wait for these plugins to complete first */
|
|
@@ -44,17 +44,17 @@ interface NavigationAfterHookContext extends NavigationHookContext {
|
|
|
44
44
|
* Runtime hooks available in Kimesh app lifecycle
|
|
45
45
|
*/
|
|
46
46
|
interface KimeshRuntimeHooks {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Runtime config shape (public values only, no SSR)
|
|
@@ -195,9 +195,9 @@ interface CreateKimeshAppOptions {
|
|
|
195
195
|
/** Base URL for router */
|
|
196
196
|
base?: string;
|
|
197
197
|
/** History mode */
|
|
198
|
-
history?:
|
|
198
|
+
history?: 'hash' | 'web';
|
|
199
199
|
/** Scroll behavior */
|
|
200
|
-
scrollBehavior?: Router[
|
|
200
|
+
scrollBehavior?: Router['options']['scrollBehavior'];
|
|
201
201
|
/** Query client configuration */
|
|
202
202
|
queryClientConfig?: QueryClientConfig;
|
|
203
203
|
/** Custom context (user-defined) */
|
|
@@ -273,7 +273,7 @@ interface RouteHeadConfig {
|
|
|
273
273
|
property?: string;
|
|
274
274
|
content?: string;
|
|
275
275
|
charset?: string;
|
|
276
|
-
|
|
276
|
+
'http-equiv'?: string;
|
|
277
277
|
[key: string]: string | undefined;
|
|
278
278
|
}>;
|
|
279
279
|
/** Link tags */
|
|
@@ -308,7 +308,7 @@ interface RouteHeadConfig {
|
|
|
308
308
|
/** HTML attributes */
|
|
309
309
|
htmlAttrs?: {
|
|
310
310
|
lang?: string;
|
|
311
|
-
dir?:
|
|
311
|
+
dir?: 'ltr' | 'rtl' | 'auto';
|
|
312
312
|
class?: string;
|
|
313
313
|
[key: string]: string | undefined;
|
|
314
314
|
};
|
|
@@ -421,7 +421,7 @@ interface FileRouteOptions<TMeta = unknown, TParams = Record<string, string>, TS
|
|
|
421
421
|
* viewTransition: 'always' // always use view transitions
|
|
422
422
|
* ```
|
|
423
423
|
*/
|
|
424
|
-
viewTransition?: boolean |
|
|
424
|
+
viewTransition?: boolean | 'always';
|
|
425
425
|
/**
|
|
426
426
|
* KeepAlive configuration for route component
|
|
427
427
|
*
|
|
@@ -456,10 +456,10 @@ interface RouteDefinition<TPath extends string = string, TMeta = unknown, TParam
|
|
|
456
456
|
beforeLoad?: (ctx: BeforeLoadContext) => Promise<void> | void;
|
|
457
457
|
head?: RouteHeadFn<TParams, TLoaderData> | RouteHeadConfig;
|
|
458
458
|
transition?: boolean | TransitionProps;
|
|
459
|
-
viewTransition?: boolean |
|
|
459
|
+
viewTransition?: boolean | 'always';
|
|
460
460
|
keepalive?: boolean | KeepAliveProps;
|
|
461
461
|
}
|
|
462
|
-
declare module
|
|
462
|
+
declare module 'vue-router' {
|
|
463
463
|
interface RouteMeta {
|
|
464
464
|
/** Kimesh route definition with loader */
|
|
465
465
|
__kimesh?: RouteDefinition;
|
|
@@ -968,7 +968,7 @@ declare function useReactiveParams<T extends string = RouteNames>(): ComputedRef
|
|
|
968
968
|
* Navigation options - requires params if route has them
|
|
969
969
|
* Allows both named routes (with autocomplete) and raw string paths
|
|
970
970
|
*/
|
|
971
|
-
type NavigateOptions<T extends string = RouteNames> = T extends RouteNames ?
|
|
971
|
+
type NavigateOptions<T extends string = RouteNames> = T extends RouteNames ? HasParams<T> extends true ? {
|
|
972
972
|
to: T;
|
|
973
973
|
params: RouteParamsRaw<T>;
|
|
974
974
|
replace?: boolean;
|
|
@@ -980,7 +980,7 @@ type NavigateOptions<T extends string = RouteNames> = T extends RouteNames ? (Ha
|
|
|
980
980
|
to: T;
|
|
981
981
|
params?: Record<string, string | number>;
|
|
982
982
|
replace?: boolean;
|
|
983
|
-
}
|
|
983
|
+
} : {
|
|
984
984
|
to: T;
|
|
985
985
|
params?: Record<string, string | number>;
|
|
986
986
|
replace?: boolean;
|
|
@@ -1132,9 +1132,9 @@ interface NavigationErrorContext {
|
|
|
1132
1132
|
to: RouteLocationNormalized;
|
|
1133
1133
|
from: RouteLocationNormalized;
|
|
1134
1134
|
}
|
|
1135
|
-
type BeforeNavigationHandler = KimeshRuntimeHooks[
|
|
1136
|
-
type AfterNavigationHandler = KimeshRuntimeHooks[
|
|
1137
|
-
type ErrorNavigationHandler = KimeshRuntimeHooks[
|
|
1135
|
+
type BeforeNavigationHandler = KimeshRuntimeHooks['navigate:before'];
|
|
1136
|
+
type AfterNavigationHandler = KimeshRuntimeHooks['navigate:after'];
|
|
1137
|
+
type ErrorNavigationHandler = KimeshRuntimeHooks['navigate:error'];
|
|
1138
1138
|
/**
|
|
1139
1139
|
* Options for useNavigationMiddleware
|
|
1140
1140
|
*/
|
|
@@ -1388,14 +1388,39 @@ declare function abortNavigation(reason?: string | Error): false;
|
|
|
1388
1388
|
//#endregion
|
|
1389
1389
|
//#region src/middleware/plugin.d.ts
|
|
1390
1390
|
/**
|
|
1391
|
-
*
|
|
1391
|
+
* Options for middleware plugin
|
|
1392
|
+
*/
|
|
1393
|
+
interface MiddlewarePluginOptions {
|
|
1394
|
+
/** Global middleware array */
|
|
1395
|
+
globalMiddleware?: RouteMiddleware[];
|
|
1396
|
+
/** Named middleware registry (lazy loaders) */
|
|
1397
|
+
namedMiddleware?: Record<string, () => Promise<RouteMiddleware>>;
|
|
1398
|
+
}
|
|
1399
|
+
/**
|
|
1400
|
+
* Create middleware plugin with provided registry
|
|
1392
1401
|
*
|
|
1393
|
-
*
|
|
1394
|
-
*
|
|
1402
|
+
* @example
|
|
1403
|
+
* ```ts
|
|
1404
|
+
* import { globalMiddleware, namedMiddleware } from '#kimesh/middleware'
|
|
1405
|
+
*
|
|
1406
|
+
* const plugin = createMiddlewarePlugin({
|
|
1407
|
+
* globalMiddleware,
|
|
1408
|
+
* namedMiddleware,
|
|
1409
|
+
* })
|
|
1410
|
+
* ```
|
|
1395
1411
|
*/
|
|
1412
|
+
declare function createMiddlewarePlugin(options?: MiddlewarePluginOptions): KimeshRuntimePlugin<{
|
|
1413
|
+
middleware: {
|
|
1414
|
+
globalCount: number;
|
|
1415
|
+
namedCount: number;
|
|
1416
|
+
};
|
|
1417
|
+
}>;
|
|
1396
1418
|
/**
|
|
1397
|
-
* Middleware runtime plugin
|
|
1398
|
-
*
|
|
1419
|
+
* Middleware runtime plugin (legacy - no-op stub)
|
|
1420
|
+
*
|
|
1421
|
+
* @deprecated Use createMiddlewarePlugin() with explicit registry instead.
|
|
1422
|
+
* This export is kept for backward compatibility but does nothing.
|
|
1423
|
+
* The kit generates middleware-plugin.mjs that uses createMiddlewarePlugin.
|
|
1399
1424
|
*/
|
|
1400
1425
|
declare const middlewarePlugin: KimeshRuntimePlugin<{
|
|
1401
1426
|
middleware: {
|
|
@@ -1434,4 +1459,4 @@ declare function createMiddlewareExecutor(appContext: KimeshAppContext): {
|
|
|
1434
1459
|
executeChain(middlewares: RouteMiddleware[], context: MiddlewareContext): Promise<void | false | NavigationRedirect>;
|
|
1435
1460
|
};
|
|
1436
1461
|
//#endregion
|
|
1437
|
-
export {
|
|
1462
|
+
export { UseSearchReturn as $, RouteParams as $t, NavigateToOptions as A, ExtractRouteParams as At, STATE_KEY_PREFIX as B, LoaderFn as Bt, KnownMiddleware as C, createFileRoute as Ct, MiddlewareRegistry as D, createKimeshApp as Dt, MiddlewareOption as E, KIMESH_APP_CONTEXT_KEY as Et, NavigationErrorContext as F, InlineRouteMiddleware as Ft, tryUseKimeshApp as G, RouteDefinition as Gt, getKmStateKeys as H, ParamValueOneOrMore as Ht, NavigationMiddlewareOptions as I, KIMESH_CONTEXT_KEY as It, useRuntimeConfig as J, RouteHeadFn as Jt, useKimeshApp as K, RouteHeadConfig as Kt, useAfterNavigation as L, KimeshApp as Lt, RouteMiddleware as M, FullContext as Mt, TypedRouteMiddleware as N, HasParams as Nt, MiddlewareRegistryEntry as O, BeforeLoadContext as Ot, NavigationContext as P, InlineMiddlewareContext as Pt, useReactiveParams as Q, RouteNames as Qt, useNavigationGuard as R, KimeshContext as Rt, KimeshMiddlewareNames as S, useKimeshContext as St, MiddlewareDefinition as T, CreateKimeshAppOptionsExtended as Tt, hasKmState as U, ParamValueZeroOrMore as Ut, clearKmState as V, ParamValue as Vt, useState as W, ParamValueZeroOrOne as Wt, useNavigate as X, RouteLocationRaw as Xt, NavigateOptions as Y, RouteInfoByName as Yt, useParams as Z, RouteNamedMap as Zt, createMiddlewarePlugin as _, getPluginHooks as _t, RouteRecordRaw$1 as a, KimeshRuntimeHooks as an, KmLink as at, defineKimeshMiddleware as b, isKimeshRuntimePlugin as bt, onBeforeRouteUpdate as c, KimeshRuntimePluginMeta as cn, QueryPluginOptions as ct, useRouter$1 as d, NavigationErrorHookContext as dn, routerPlugin as dt, RouteParamsRaw as en, useSearch as et, createMiddlewareExecutor as f, NavigationHookContext as fn, applyPlugin as ft, MiddlewarePluginOptions as g, defineKimeshRuntimePlugin as gt, createMiddlewareContext as h, KIMESH_PLUGIN_INDICATOR as ht, RouteLocationNormalizedLoaded$1 as i, KimeshAppContext as in, KmDeferred as it, NavigationRedirect as j, FileRouteOptions as jt, MiddlewareResult as k, CreateKimeshAppOptions as kt, useLink as l, KimeshRuntimePluginResult as ln, getCorePlugins as lt, executeMiddlewareChain as m, applyPluginsWithParallel as mt, NavigationHookAfter as n, RouteRecordInfo as nn, createLoaderGuard as nt, Router$1 as o, KimeshRuntimePlugin as on, KmLinkProps as ot, executeMiddleware as p, RuntimeConfigPublic as pn, applyPlugins as pt, RuntimeConfig as q, RouteHeadContext as qt, RouteLocationNormalized$1 as r, SearchSchema as rn, installLoaderGuard as rt, onBeforeRouteLeave as s, KimeshRuntimePluginDefinition as sn, KmOutlet as st, NavigationGuard as t, RoutePath as tn, LoaderGuardOptions as tt, useRoute$1 as u, NavigationAfterHookContext as un, queryPlugin as ut, middlewarePlugin as v, getPluginMeta as vt, MiddlewareContext as w, defineRoute as wt, navigateTo as x, defineContext as xt, abortNavigation as y, getPluginName as yt, useNavigationMiddleware as z, LoaderContext as zt };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { BeforeLoadContext, CreateKimeshAppOptions, CreateKimeshAppOptionsExtended, ExtractRouteParams, FileRouteOptions, FullContext, HasParams, 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, LoaderContext, LoaderFn, LoaderGuardOptions, MiddlewareContext, MiddlewareDefinition, MiddlewareOption, MiddlewareResult, NavigateOptions, NavigateToOptions, NavigationAfterHookContext, NavigationContext, NavigationErrorContext, NavigationErrorHookContext, NavigationGuard, NavigationHookAfter, NavigationHookContext, NavigationMiddlewareOptions, NavigationRedirect, ParamValue, ParamValueOneOrMore, ParamValueZeroOrMore, ParamValueZeroOrOne, QueryPluginOptions, RouteDefinition, RouteHeadConfig, RouteHeadContext, RouteHeadFn, RouteInfoByName, RouteLocationNormalized, RouteLocationNormalizedLoaded, RouteLocationRaw, RouteMiddleware, RouteNamedMap, RouteNames, RouteParams, RouteParamsRaw, RoutePath, RouteRecordInfo, RouteRecordRaw, Router, RuntimeConfig, RuntimeConfigPublic, STATE_KEY_PREFIX, SearchSchema, TypedRouteMiddleware, UseSearchReturn, abortNavigation, applyPlugin, applyPlugins, applyPluginsWithParallel, clearKmState, createFileRoute, createKimeshApp, createLoaderGuard, createMiddlewareContext, createMiddlewareExecutor, defineContext, defineKimeshMiddleware, defineKimeshRuntimePlugin, defineRoute, getCorePlugins, getKmStateKeys, getPluginHooks, getPluginMeta, getPluginName, hasKmState, installLoaderGuard, isKimeshRuntimePlugin, middlewarePlugin, navigateTo, onBeforeRouteLeave, onBeforeRouteUpdate, queryPlugin, routerPlugin, tryUseKimeshApp, useAfterNavigation, useKimeshApp, useKimeshContext, useLink, useNavigate, useNavigationGuard, useNavigationMiddleware, useParams, useReactiveParams, useRoute, useRouter, useRuntimeConfig, useSearch, useState };
|
|
1
|
+
import { $ as UseSearchReturn, $t as RouteParams, A as NavigateToOptions, At as ExtractRouteParams, B as STATE_KEY_PREFIX, Bt as LoaderFn, C as KnownMiddleware, Ct as createFileRoute, Dt as createKimeshApp, E as MiddlewareOption, Et as KIMESH_APP_CONTEXT_KEY, F as NavigationErrorContext, Ft as InlineRouteMiddleware, G as tryUseKimeshApp, Gt as RouteDefinition, H as getKmStateKeys, Ht as ParamValueOneOrMore, I as NavigationMiddlewareOptions, It as KIMESH_CONTEXT_KEY, J as useRuntimeConfig, Jt as RouteHeadFn, K as useKimeshApp, Kt as RouteHeadConfig, L as useAfterNavigation, Lt as KimeshApp, M as RouteMiddleware, Mt as FullContext, N as TypedRouteMiddleware, Nt as HasParams, Ot as BeforeLoadContext, P as NavigationContext, Pt as InlineMiddlewareContext, Q as useReactiveParams, Qt as RouteNames, R as useNavigationGuard, Rt as KimeshContext, S as KimeshMiddlewareNames, St as useKimeshContext, T as MiddlewareDefinition, Tt as CreateKimeshAppOptionsExtended, U as hasKmState, Ut as ParamValueZeroOrMore, V as clearKmState, Vt as ParamValue, W as useState, Wt as ParamValueZeroOrOne, X as useNavigate, Xt as RouteLocationRaw, Y as NavigateOptions, Yt as RouteInfoByName, Z as useParams, Zt as RouteNamedMap, _ as createMiddlewarePlugin, _t as getPluginHooks, a as RouteRecordRaw, an as KimeshRuntimeHooks, at as KmLink, b as defineKimeshMiddleware, bt as isKimeshRuntimePlugin, c as onBeforeRouteUpdate, cn as KimeshRuntimePluginMeta, ct as QueryPluginOptions, d as useRouter, dn as NavigationErrorHookContext, dt as routerPlugin, en as RouteParamsRaw, et as useSearch, f as createMiddlewareExecutor, fn as NavigationHookContext, ft as applyPlugin, g as MiddlewarePluginOptions, gt as defineKimeshRuntimePlugin, h as createMiddlewareContext, ht as KIMESH_PLUGIN_INDICATOR, i as RouteLocationNormalizedLoaded, in as KimeshAppContext, it as KmDeferred, j as NavigationRedirect, jt as FileRouteOptions, k as MiddlewareResult, kt as CreateKimeshAppOptions, l as useLink, ln as KimeshRuntimePluginResult, lt as getCorePlugins, mt as applyPluginsWithParallel, n as NavigationHookAfter, nn as RouteRecordInfo, nt as createLoaderGuard, o as Router, on as KimeshRuntimePlugin, ot as KmLinkProps, pn as RuntimeConfigPublic, pt as applyPlugins, q as RuntimeConfig, qt as RouteHeadContext, r as RouteLocationNormalized, rn as SearchSchema, rt as installLoaderGuard, s as onBeforeRouteLeave, sn as KimeshRuntimePluginDefinition, st as KmOutlet, t as NavigationGuard, tn as RoutePath, tt as LoaderGuardOptions, u as useRoute, un as NavigationAfterHookContext, ut as queryPlugin, v as middlewarePlugin, vt as getPluginMeta, w as MiddlewareContext, wt as defineRoute, x as navigateTo, xt as defineContext, y as abortNavigation, yt as getPluginName, z as useNavigationMiddleware, zt as LoaderContext } from "./index-9xJk3v3Z.mjs";
|
|
2
|
+
export { BeforeLoadContext, CreateKimeshAppOptions, CreateKimeshAppOptionsExtended, ExtractRouteParams, FileRouteOptions, FullContext, HasParams, 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, LoaderContext, LoaderFn, LoaderGuardOptions, MiddlewareContext, MiddlewareDefinition, MiddlewareOption, MiddlewarePluginOptions, MiddlewareResult, NavigateOptions, NavigateToOptions, NavigationAfterHookContext, NavigationContext, NavigationErrorContext, NavigationErrorHookContext, NavigationGuard, NavigationHookAfter, NavigationHookContext, NavigationMiddlewareOptions, NavigationRedirect, ParamValue, ParamValueOneOrMore, ParamValueZeroOrMore, ParamValueZeroOrOne, QueryPluginOptions, RouteDefinition, RouteHeadConfig, RouteHeadContext, RouteHeadFn, RouteInfoByName, RouteLocationNormalized, RouteLocationNormalizedLoaded, RouteLocationRaw, RouteMiddleware, RouteNamedMap, RouteNames, RouteParams, RouteParamsRaw, RoutePath, RouteRecordInfo, RouteRecordRaw, Router, RuntimeConfig, RuntimeConfigPublic, STATE_KEY_PREFIX, SearchSchema, TypedRouteMiddleware, UseSearchReturn, abortNavigation, applyPlugin, applyPlugins, applyPluginsWithParallel, clearKmState, createFileRoute, createKimeshApp, createLoaderGuard, createMiddlewareContext, createMiddlewareExecutor, createMiddlewarePlugin, defineContext, defineKimeshMiddleware, defineKimeshRuntimePlugin, defineRoute, getCorePlugins, getKmStateKeys, getPluginHooks, getPluginMeta, getPluginName, hasKmState, installLoaderGuard, isKimeshRuntimePlugin, middlewarePlugin, navigateTo, onBeforeRouteLeave, onBeforeRouteUpdate, queryPlugin, routerPlugin, tryUseKimeshApp, useAfterNavigation, useKimeshApp, useKimeshContext, useLink, useNavigate, useNavigationGuard, useNavigationMiddleware, useParams, useReactiveParams, useRoute, useRouter, useRuntimeConfig, useSearch, useState };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
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-BfxCqV0B.mjs";
|
|
2
2
|
import { a as defineKimeshMiddleware, i as abortNavigation, o as navigateTo, t as createMiddlewareExecutor } from "./middleware-DdlzhfiB.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";
|
|
@@ -359,12 +359,12 @@ function defineRoute(options) {
|
|
|
359
359
|
//#region src/context.ts
|
|
360
360
|
/**
|
|
361
361
|
* Define app context with type inference
|
|
362
|
-
*
|
|
362
|
+
*
|
|
363
363
|
* @example
|
|
364
364
|
* ```ts
|
|
365
365
|
* // src/app.context.ts
|
|
366
366
|
* import { defineContext } from '@kimesh/router-runtime'
|
|
367
|
-
*
|
|
367
|
+
*
|
|
368
368
|
* export default defineContext(() => ({
|
|
369
369
|
* auth: useAuthStore(),
|
|
370
370
|
* i18n: createI18n(),
|
|
@@ -376,7 +376,7 @@ function defineContext(factory) {
|
|
|
376
376
|
}
|
|
377
377
|
/**
|
|
378
378
|
* Use Kimesh context in components
|
|
379
|
-
*
|
|
379
|
+
*
|
|
380
380
|
* @example
|
|
381
381
|
* ```vue
|
|
382
382
|
* <script setup>
|
|
@@ -599,17 +599,17 @@ const supportsViewTransitions = () => typeof document !== "undefined" && "startV
|
|
|
599
599
|
* Renders the matched route component with optional transitions and keepalive
|
|
600
600
|
*
|
|
601
601
|
* Transition options for async pages (useSuspenseQuery):
|
|
602
|
-
*
|
|
602
|
+
*
|
|
603
603
|
* 1. viewTransition: true (Recommended)
|
|
604
604
|
* - Uses View Transitions API (Chrome 111+, Edge 111+, Opera 97+)
|
|
605
605
|
* - Works perfectly with async pages
|
|
606
606
|
* - Falls back to instant transition on unsupported browsers
|
|
607
|
-
*
|
|
607
|
+
*
|
|
608
608
|
* 2. transition: { name: 'fade' } (without mode: 'out-in')
|
|
609
609
|
* - Uses Vue Transition with default mode (cross-fade)
|
|
610
610
|
* - Both pages exist during transition (old fades out, new fades in)
|
|
611
611
|
* - Requires CSS: .page-leave-active { position: absolute }
|
|
612
|
-
*
|
|
612
|
+
*
|
|
613
613
|
* 3. transition: { name: 'fade', mode: 'out-in' }
|
|
614
614
|
* - ⚠️ NOT recommended for async pages - may cause blank screen
|
|
615
615
|
*/
|
|
@@ -1066,7 +1066,7 @@ let _config;
|
|
|
1066
1066
|
*/
|
|
1067
1067
|
function useRuntimeConfig() {
|
|
1068
1068
|
if (!_config) try {
|
|
1069
|
-
_config = Object.freeze({ ...__KIMESH_CONFIG__
|
|
1069
|
+
_config = Object.freeze({ ...__KIMESH_CONFIG__ });
|
|
1070
1070
|
} catch {
|
|
1071
1071
|
_config = Object.freeze({});
|
|
1072
1072
|
}
|
|
@@ -1239,4 +1239,4 @@ function useAfterNavigation(callback) {
|
|
|
1239
1239
|
}
|
|
1240
1240
|
|
|
1241
1241
|
//#endregion
|
|
1242
|
-
export { KIMESH_APP_CONTEXT_KEY, KIMESH_CONTEXT_KEY, KIMESH_PLUGIN_INDICATOR, KmDeferred, KmLink, KmOutlet, STATE_KEY_PREFIX, abortNavigation, applyPlugin, applyPlugins, applyPluginsWithParallel, clearKmState, createFileRoute, createKimeshApp, createLoaderGuard, createMiddlewareContext, createMiddlewareExecutor, defineContext, defineKimeshMiddleware, defineKimeshRuntimePlugin, defineRoute, getCorePlugins, getKmStateKeys, getPluginHooks, getPluginMeta, getPluginName, hasKmState, installLoaderGuard, isKimeshRuntimePlugin, middlewarePlugin, navigateTo, onBeforeRouteLeave, onBeforeRouteUpdate, queryPlugin, routerPlugin, tryUseKimeshApp, useAfterNavigation, useKimeshApp, useKimeshContext, useLink, useNavigate, useNavigationGuard, useNavigationMiddleware, useParams, useReactiveParams, useRoute, useRouter, useRuntimeConfig, useSearch, useState };
|
|
1242
|
+
export { KIMESH_APP_CONTEXT_KEY, KIMESH_CONTEXT_KEY, KIMESH_PLUGIN_INDICATOR, KmDeferred, KmLink, KmOutlet, STATE_KEY_PREFIX, abortNavigation, applyPlugin, applyPlugins, applyPluginsWithParallel, clearKmState, createFileRoute, createKimeshApp, createLoaderGuard, createMiddlewareContext, createMiddlewareExecutor, createMiddlewarePlugin, defineContext, defineKimeshMiddleware, defineKimeshRuntimePlugin, defineRoute, getCorePlugins, getKmStateKeys, getPluginHooks, getPluginMeta, getPluginName, hasKmState, installLoaderGuard, isKimeshRuntimePlugin, middlewarePlugin, navigateTo, onBeforeRouteLeave, onBeforeRouteUpdate, queryPlugin, routerPlugin, tryUseKimeshApp, useAfterNavigation, useKimeshApp, useKimeshContext, useLink, useNavigate, useNavigationGuard, useNavigationMiddleware, useParams, useReactiveParams, useRoute, useRouter, useRuntimeConfig, useSearch, useState };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { KimeshMiddlewareNames, KnownMiddleware, MiddlewareContext, MiddlewareDefinition, MiddlewareOption, MiddlewareRegistry, MiddlewareRegistryEntry, MiddlewareResult, NavigateToOptions, NavigationRedirect, RouteMiddleware, TypedRouteMiddleware, abortNavigation, createMiddlewareContext, createMiddlewareExecutor, defineKimeshMiddleware, executeMiddleware, executeMiddlewareChain, middlewarePlugin, navigateTo };
|
|
1
|
+
import { A as NavigateToOptions, C as KnownMiddleware, D as MiddlewareRegistry, E as MiddlewareOption, M as RouteMiddleware, N as TypedRouteMiddleware, O as MiddlewareRegistryEntry, S as KimeshMiddlewareNames, T as MiddlewareDefinition, _ as createMiddlewarePlugin, b as defineKimeshMiddleware, f as createMiddlewareExecutor, g as MiddlewarePluginOptions, h as createMiddlewareContext, j as NavigationRedirect, k as MiddlewareResult, m as executeMiddlewareChain, p as executeMiddleware, v as middlewarePlugin, w as MiddlewareContext, x as navigateTo, y as abortNavigation } from "../index-9xJk3v3Z.mjs";
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as createMiddlewareContext, n as middlewarePlugin, t as createMiddlewarePlugin } from "../plugin-BfxCqV0B.mjs";
|
|
2
2
|
import { a as defineKimeshMiddleware, i as abortNavigation, n as executeMiddleware, o as navigateTo, r as executeMiddlewareChain, t as createMiddlewareExecutor } from "../middleware-DdlzhfiB.mjs";
|
|
3
3
|
|
|
4
|
-
export { abortNavigation, createMiddlewareContext, createMiddlewareExecutor, defineKimeshMiddleware, executeMiddleware, executeMiddlewareChain, middlewarePlugin, navigateTo };
|
|
4
|
+
export { abortNavigation, createMiddlewareContext, createMiddlewareExecutor, createMiddlewarePlugin, defineKimeshMiddleware, executeMiddleware, executeMiddlewareChain, middlewarePlugin, navigateTo };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { g as middlewarePlugin } from "../index-
|
|
2
|
-
export { middlewarePlugin as default, middlewarePlugin };
|
|
1
|
+
import { _ as createMiddlewarePlugin, g as MiddlewarePluginOptions, v as middlewarePlugin } from "../index-9xJk3v3Z.mjs";
|
|
2
|
+
export { MiddlewarePluginOptions, createMiddlewarePlugin, middlewarePlugin as default, middlewarePlugin };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as plugin_default, t as
|
|
1
|
+
import { n as middlewarePlugin, r as plugin_default, t as createMiddlewarePlugin } from "../plugin-BfxCqV0B.mjs";
|
|
2
2
|
|
|
3
|
-
export { plugin_default as default, middlewarePlugin };
|
|
3
|
+
export { createMiddlewarePlugin, plugin_default as default, middlewarePlugin };
|
|
@@ -92,48 +92,62 @@ function createMiddlewareContext(to, from, appContext) {
|
|
|
92
92
|
*
|
|
93
93
|
* Runtime plugin that integrates middleware execution with Vue Router.
|
|
94
94
|
* Executes middleware in router.beforeEach guard.
|
|
95
|
+
*
|
|
96
|
+
* This plugin receives middleware registry from options instead of importing
|
|
97
|
+
* virtual modules, avoiding Vite pre-bundling issues.
|
|
95
98
|
*/
|
|
96
99
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
100
|
+
* Create middleware plugin with provided registry
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* import { globalMiddleware, namedMiddleware } from '#kimesh/middleware'
|
|
105
|
+
*
|
|
106
|
+
* const plugin = createMiddlewarePlugin({
|
|
107
|
+
* globalMiddleware,
|
|
108
|
+
* namedMiddleware,
|
|
109
|
+
* })
|
|
110
|
+
* ```
|
|
99
111
|
*/
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
function createMiddlewarePlugin(options = {}) {
|
|
113
|
+
const globalMiddleware = options.globalMiddleware || [];
|
|
114
|
+
const namedMiddleware = options.namedMiddleware || {};
|
|
115
|
+
const hasMiddleware = globalMiddleware.length > 0 || Object.keys(namedMiddleware).length > 0;
|
|
116
|
+
return defineKimeshRuntimePlugin({
|
|
117
|
+
name: "kimesh:middleware",
|
|
118
|
+
enforce: "pre",
|
|
119
|
+
setup(appContext) {
|
|
120
|
+
if (__KIMESH_DEV__ && hasMiddleware) console.info(`[Kimesh] Middleware loaded: ${globalMiddleware.length} global, ${Object.keys(namedMiddleware).length} named`);
|
|
121
|
+
if (hasMiddleware) appContext.router.beforeEach(async (to, from) => {
|
|
122
|
+
const context = createMiddlewareContext(to, from, appContext);
|
|
123
|
+
for (const middleware of globalMiddleware) {
|
|
124
|
+
if (__KIMESH_DEV__) console.debug("[Kimesh] Executing global middleware");
|
|
125
|
+
const result = await appContext.runWithContext(() => middleware(to, from, context));
|
|
126
|
+
if (result !== void 0) return convertResult(result);
|
|
127
|
+
}
|
|
128
|
+
const routeMiddleware = await extractRouteMiddleware(to, namedMiddleware);
|
|
129
|
+
if (__KIMESH_DEV__ && routeMiddleware.length > 0) console.debug(`[Kimesh] Executing ${routeMiddleware.length} route middleware`);
|
|
130
|
+
for (const middleware of routeMiddleware) {
|
|
131
|
+
const result = await appContext.runWithContext(() => middleware(to, from, context));
|
|
132
|
+
if (result !== void 0) return convertResult(result);
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
});
|
|
136
|
+
return { provide: { middleware: {
|
|
137
|
+
globalCount: globalMiddleware.length,
|
|
138
|
+
namedCount: Object.keys(namedMiddleware).length
|
|
139
|
+
} } };
|
|
115
140
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const result = await appContext.runWithContext(() => middleware(to, from, context));
|
|
127
|
-
if (result !== void 0) return convertResult(result);
|
|
128
|
-
}
|
|
129
|
-
return true;
|
|
130
|
-
});
|
|
131
|
-
return { provide: { middleware: {
|
|
132
|
-
globalCount: globalMiddleware.length,
|
|
133
|
-
namedCount: Object.keys(namedMiddleware).length
|
|
134
|
-
} } };
|
|
135
|
-
}
|
|
136
|
-
});
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Middleware runtime plugin (legacy - no-op stub)
|
|
145
|
+
*
|
|
146
|
+
* @deprecated Use createMiddlewarePlugin() with explicit registry instead.
|
|
147
|
+
* This export is kept for backward compatibility but does nothing.
|
|
148
|
+
* The kit generates middleware-plugin.mjs that uses createMiddlewarePlugin.
|
|
149
|
+
*/
|
|
150
|
+
const middlewarePlugin = createMiddlewarePlugin({});
|
|
137
151
|
/**
|
|
138
152
|
* Convert middleware result to Vue Router format
|
|
139
153
|
*/
|
|
@@ -192,4 +206,4 @@ async function normalizeMiddleware(middleware, namedMiddleware) {
|
|
|
192
206
|
var plugin_default = middlewarePlugin;
|
|
193
207
|
|
|
194
208
|
//#endregion
|
|
195
|
-
export {
|
|
209
|
+
export { KIMESH_PLUGIN_INDICATOR as a, getPluginMeta as c, createMiddlewareContext as i, getPluginName as l, middlewarePlugin as n, defineKimeshRuntimePlugin as o, plugin_default as r, getPluginHooks as s, createMiddlewarePlugin as t, isKimeshRuntimePlugin as u };
|
package/package.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kimesh/router-runtime",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11-nightly.20260127015259",
|
|
4
4
|
"description": "Runtime router for Kimesh framework",
|
|
5
|
-
"type": "module",
|
|
6
5
|
"repository": {
|
|
7
6
|
"type": "git",
|
|
8
7
|
"url": "https://github.com/kimeshjs/kimesh.git"
|
|
9
8
|
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"src/default-app.vue"
|
|
12
|
+
],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "./dist/index.mjs",
|
|
15
|
+
"types": "./dist/index.d.mts",
|
|
10
16
|
"exports": {
|
|
11
17
|
".": {
|
|
12
18
|
"types": "./dist/index.d.mts",
|
|
@@ -24,12 +30,6 @@
|
|
|
24
30
|
"import": "./dist/middleware/plugin.mjs"
|
|
25
31
|
}
|
|
26
32
|
},
|
|
27
|
-
"main": "./dist/index.mjs",
|
|
28
|
-
"types": "./dist/index.d.mts",
|
|
29
|
-
"files": [
|
|
30
|
-
"dist",
|
|
31
|
-
"src/default-app.vue"
|
|
32
|
-
],
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsdown",
|
|
35
35
|
"dev": "tsdown --watch",
|
|
@@ -41,22 +41,22 @@
|
|
|
41
41
|
"hookable": "^5.5.3",
|
|
42
42
|
"vue-router": "^4.6.4"
|
|
43
43
|
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@tanstack/vue-query": "^5.92.6",
|
|
46
|
+
"@types/node": "^25.0.8",
|
|
47
|
+
"tsdown": "^0.20.0-beta.3",
|
|
48
|
+
"typescript": "^5.9.3",
|
|
49
|
+
"vitest": "^4.0.17",
|
|
50
|
+
"vue": "^3.5.26",
|
|
51
|
+
"vue-tsc": "^3.2.2"
|
|
52
|
+
},
|
|
44
53
|
"peerDependencies": {
|
|
45
|
-
"vue": "^
|
|
46
|
-
"
|
|
54
|
+
"@tanstack/vue-query": "^5.0.0",
|
|
55
|
+
"vue": "^3.5.0"
|
|
47
56
|
},
|
|
48
57
|
"peerDependenciesMeta": {
|
|
49
58
|
"@tanstack/vue-query": {
|
|
50
59
|
"optional": true
|
|
51
60
|
}
|
|
52
|
-
},
|
|
53
|
-
"devDependencies": {
|
|
54
|
-
"@types/node": "^25.0.8",
|
|
55
|
-
"typescript": "^5.9.3",
|
|
56
|
-
"tsdown": "^0.20.0-beta.3",
|
|
57
|
-
"vue": "^3.5.26",
|
|
58
|
-
"vue-tsc": "^3.2.2",
|
|
59
|
-
"vitest": "^4.0.17",
|
|
60
|
-
"@tanstack/vue-query": "^5.92.6"
|
|
61
61
|
}
|
|
62
62
|
}
|