@flue3/router
Advanced tools
Comparing version 0.0.20-dev.0 to 0.0.21-dev.0
import { RouterPluginOptions } from '../types'; | ||
export declare const defineLayouts: (layouts: RouterPluginOptions['layouts']) => import("../types").LayoutComponentsRecord | ((appContext: import("flue3/lib/types/AppContext.js").AppContext) => import("../types").LayoutComponentsRecord | Promise<import("../types").LayoutComponentsRecord | { | ||
export declare const defineLayouts: (layouts: RouterPluginOptions['layouts']) => import("../types").LayoutComponentsRecord | ((appContext: import("flue3").AppContext) => import("../types").LayoutComponentsRecord | Promise<import("../types").LayoutComponentsRecord | { | ||
default: import("../types").LayoutComponentsRecord; | ||
}>) | undefined; |
import { RouterPluginOptions } from '../types'; | ||
export declare const defineRoutes: (routes: RouterPluginOptions['routes']) => import("vue-router").RouteRecordRaw[] | ((appContext: import("flue3/lib/types/AppContext.js").AppContext) => import("vue-router").RouteRecordRaw[] | Promise<import("vue-router").RouteRecordRaw[] | { | ||
default: import("vue-router").RouteRecordRaw[]; | ||
export declare const defineRoutes: (routes: RouterPluginOptions['routes']) => import("../types").RouteRecord[] | ((appContext: import("flue3").AppContext) => import("../types").RouteRecord[] | Promise<import("../types").RouteRecord[] | { | ||
default: import("../types").RouteRecord[]; | ||
}>); |
@@ -8,7 +8,8 @@ import { createRouter, createWebHistory, createMemoryHistory, } from 'vue-router'; | ||
import { proceedUncertainModuleFunc } from 'flue3/lib/utils/proceedUncertainModuleFunc.js'; | ||
export const createRouterPlugin = definePlugin(async ({ appContext, inject, onAfterEntry, }, options) => { | ||
import { parseRoutesRecordToRaw } from './utils.js'; | ||
export const createRouterPlugin = definePlugin(async ({ appContext, inject, }, options) => { | ||
const routes = await proceedUncertainModuleFunc(options.routes, appContext); | ||
const layouts = await proceedUncertainModuleFunc(options.layouts, appContext); | ||
const router = createRouter({ | ||
routes: [...routes, ...pluginRoutes], | ||
routes: [...parseRoutesRecordToRaw(routes), ...pluginRoutes], | ||
scrollBehavior: options.scrollBehavior, | ||
@@ -38,3 +39,3 @@ history: appContext.isServer ? createMemoryHistory() : createWebHistory(), | ||
createErrorStateMiddleware(appContext); | ||
onAfterEntry(async () => { | ||
appContext.hooks.hook('entry:after', async () => { | ||
createRoutesMiddleware(appContext); | ||
@@ -41,0 +42,0 @@ if (appContext.isServer) { |
import { Component } from 'vue'; | ||
import { RouteRecordRaw, RouterScrollBehavior } from 'vue-router'; | ||
import { AppContext } from 'flue3/lib/types/AppContext.js'; | ||
import { AppMiddleware } from 'flue3/src/types/AppMiddleware.js'; | ||
export type LayoutComponent = (() => Promise<Component | { | ||
@@ -8,6 +9,12 @@ default: Component; | ||
export type LayoutComponentsRecord = Record<string, LayoutComponent>; | ||
export type RouteRecordCustomProps = { | ||
layout?: string; | ||
middleware?: AppMiddleware | AppMiddleware[]; | ||
children?: RouteRecord[]; | ||
}; | ||
export type RouteRecord = RouteRecordRaw & RouteRecordCustomProps; | ||
export interface RouterPluginOptions { | ||
routes: ((appContext: AppContext) => RouteRecordRaw[] | Promise<RouteRecordRaw[] | { | ||
default: RouteRecordRaw[]; | ||
}>) | RouteRecordRaw[]; | ||
routes: ((appContext: AppContext) => RouteRecord[] | Promise<RouteRecord[] | { | ||
default: RouteRecord[]; | ||
}>) | RouteRecord[]; | ||
layouts?: ((appContext: AppContext) => LayoutComponentsRecord | Promise<LayoutComponentsRecord | { | ||
@@ -14,0 +21,0 @@ default: LayoutComponentsRecord; |
{ | ||
"name": "@flue3/router", | ||
"version": "0.0.20-dev.0", | ||
"version": "0.0.21-dev.0", | ||
"description": "flue3 <head> tag manager plugin", | ||
@@ -22,7 +22,8 @@ "author": "FL3NKEY", | ||
"devDependencies": { | ||
"flue3": "*", | ||
"flue3": "^0.0.21-dev.0", | ||
"vue": "3.2.45" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
"access": "public", | ||
"registry": "https://registry.npmjs.org/" | ||
}, | ||
@@ -29,0 +30,0 @@ "dependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12014
28
278