Skip to content

Commit 355431b

Browse files
committed
fix: expose resolveOptions for unplugin
1 parent e3bf720 commit 355431b

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

packages/router/src/unplugin/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ import { join } from 'pathe'
2222
import { appendExtensionListToPattern } from './core/utils'
2323
import { createAutoExportPlugin } from '../experimental/data-loaders/auto-exports'
2424

25-
export type { Options } from './options'
25+
export type {
26+
Options,
27+
ResolvedOptions,
28+
RoutesFolder,
29+
RoutesFolderOption,
30+
RoutesFolderOptionResolved,
31+
ParamParsersOptions,
32+
} from './options'
33+
export { resolveOptions } from './options'
2634
export type { TreeNode } from './core/tree'
2735
export type {
2836
TreeNodeValue,

packages/router/src/unplugin/options.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,25 @@ export interface RoutesFolderOptionResolved extends RoutesFolderOption {
8383
extensions: string[]
8484
}
8585

86+
/**
87+
* An option that can be overridden by providing a function that receives the
88+
* existing value and returns a new one.
89+
*
90+
* @internal
91+
*/
8692
export type _OverridableOption<T, AllowedTypes = T> =
8793
| AllowedTypes
8894
| ((existing: T) => T)
8995

9096
/**
91-
* Resolves an overridable option by calling the function with the existing value if it's a function, otherwise
92-
* returning the passed `value`. If `value` is undefined, it returns the `defaultValue` instead.
97+
* Resolves an overridable option by calling the function with the existing
98+
* value if it's a function, otherwise returning the passed `value`. If `value`
99+
* is undefined, it returns the `defaultValue` instead.
93100
*
94101
* @param defaultValue default value for the option
95102
* @param value and overridable option
103+
*
104+
* @internal
96105
*/
97106
export function resolveOverridableOption<T>(
98107
defaultValue: T,
@@ -103,7 +112,14 @@ export function resolveOverridableOption<T>(
103112
: (value ?? defaultValue)
104113
}
105114

115+
/**
116+
* @internal
117+
*/
106118
export type _RoutesFolder = string | RoutesFolderOption
119+
120+
/**
121+
* Type for the {@link Options.routesFolder} option.
122+
*/
107123
export type RoutesFolder = _RoutesFolder[] | _RoutesFolder
108124

109125
/**
@@ -151,7 +167,7 @@ export interface Options {
151167
getRouteName?: (node: TreeNode) => string
152168

153169
/**
154-
* Allows to extend a route by modifying its node, adding children, or even deleting it. This will be invoked once for
170+
* Allows extending a route by modifying its node, adding children, or even deleting it. This will be invoked once for
155171
* each route.
156172
*
157173
* @param route - {@link EditableTreeNode} of the route to extend
@@ -236,6 +252,9 @@ export interface Options {
236252
}
237253
}
238254

255+
/**
256+
* Options for experimental param parsers.
257+
*/
239258
export interface ParamParsersOptions {
240259
/**
241260
* Folder(s) to scan for param matchers. Set to an empty array to disable the feature.
@@ -245,10 +264,16 @@ export interface ParamParsersOptions {
245264
dir?: string | string[]
246265
}
247266

267+
/**
268+
* Default options for experimental param parsers.
269+
*/
248270
export const DEFAULT_PARAM_PARSERS_OPTIONS = {
249271
dir: ['src/params'],
250272
} satisfies Required<ParamParsersOptions>
251273

274+
/**
275+
* Default plugin options.
276+
*/
252277
export const DEFAULT_OPTIONS = {
253278
extensions: ['.vue'],
254279
exclude: [],
@@ -268,6 +293,11 @@ export const DEFAULT_OPTIONS = {
268293
experimental: {},
269294
} satisfies Options
270295

296+
/**
297+
* Expected server context provided to hooks.
298+
*
299+
* @internal
300+
*/
271301
export interface ServerContext {
272302
/**
273303
* Invalidates a module by its id.

0 commit comments

Comments
 (0)