From: Eduardo San Martin Morote Date: Mon, 18 Aug 2025 11:22:44 +0000 (+0200) Subject: feat: expose internal mergeRouteRecord X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=135cbab3632536c2634e2052afeec42b8b570057;p=thirdparty%2Fvuejs%2Frouter.git feat: expose internal mergeRouteRecord --- diff --git a/packages/router/src/experimental/index.ts b/packages/router/src/experimental/index.ts index a504af1d..e16fe505 100644 --- a/packages/router/src/experimental/index.ts +++ b/packages/router/src/experimental/index.ts @@ -39,6 +39,13 @@ export { export { miss, MatchMiss } from './route-resolver/matchers/errors' +/** + * Internal functions and types for the experimental router. + * They should all be prefixed with `_` to avoid conflicts with the public API. + */ + +export { mergeRouteRecord as _mergeRouteRecord } from './router' + // in the new experimental router, there are only parents // this should create type errors if someone is realying on children declare module 'vue-router' { diff --git a/packages/router/src/experimental/router.ts b/packages/router/src/experimental/router.ts index 0cd04e7c..1b12a122 100644 --- a/packages/router/src/experimental/router.ts +++ b/packages/router/src/experimental/router.ts @@ -370,6 +370,27 @@ export function normalizeRouteRecord( | EXPERIMENTAL_RouteRecordNormalized_Group } +/** + * Merges route record objects for the experimental resolver format. + * This function is specifically designed to work with objects that will be passed to normalizeRouteRecord(). + * + * @internal + * + * @param main - main route record object + * @param routeRecords - route records to merge (from definePage imports) + * @returns merged route record object + */ +export function mergeRouteRecord( + main: EXPERIMENTAL_RouteRecordNormalized, + // TODO: actual type + ...routeRecords: Partial[] +) { + for (const record of routeRecords) { + main.meta = { ...main.meta, ...record.meta } + } + return main +} + // TODO: probably need some generic types // , /**