]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
feat: expose internal mergeRouteRecord
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 18 Aug 2025 11:22:44 +0000 (13:22 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 18 Aug 2025 11:22:44 +0000 (13:22 +0200)
packages/router/src/experimental/index.ts
packages/router/src/experimental/router.ts

index a504af1d5ed2f481c5da33c2e34e4765d91abf57..e16fe505a96263c22fce5ea376311d41ff7ee6cf 100644 (file)
@@ -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' {
index 0cd04e7ca1240f9546fdecc37dff49e8db0bf20e..1b12a122418a2da121f1e48764bb2797f2f8f028 100644 (file)
@@ -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<EXPERIMENTAL_RouteRecordNormalized>[]
+) {
+  for (const record of routeRecords) {
+    main.meta = { ...main.meta, ...record.meta }
+  }
+  return main
+}
+
 // TODO: probably need some generic types
 // <TResolver extends NEW_RouterResolver_Base>,
 /**