@kimesh/router-runtime 0.2.10 → 0.2.11
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-CYE7fnU0.d.mts} +31 -6
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- 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 +1 -1
|
@@ -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-CYE7fnU0.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";
|
|
@@ -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-CYE7fnU0.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-CYE7fnU0.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 };
|