From f78a5bea8aaa39be0da37d79f50655e0384db58d Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Sun, 29 Jun 2025 22:24:30 +0200 Subject: [PATCH 01/27] chore: playground layout group --- playground/src/pages/(some-layout).vue | 7 +++++++ playground/src/pages/(some-layout)/app.vue | 3 +++ playground/src/pages/(some-layout)/home.vue | 3 +++ playground/typed-router.d.ts | 3 +++ 4 files changed, 16 insertions(+) create mode 100644 playground/src/pages/(some-layout).vue create mode 100644 playground/src/pages/(some-layout)/app.vue create mode 100644 playground/src/pages/(some-layout)/home.vue diff --git a/playground/src/pages/(some-layout).vue b/playground/src/pages/(some-layout).vue new file mode 100644 index 000000000..42463140e --- /dev/null +++ b/playground/src/pages/(some-layout).vue @@ -0,0 +1,7 @@ + diff --git a/playground/src/pages/(some-layout)/app.vue b/playground/src/pages/(some-layout)/app.vue new file mode 100644 index 000000000..de7a313ea --- /dev/null +++ b/playground/src/pages/(some-layout)/app.vue @@ -0,0 +1,3 @@ + diff --git a/playground/src/pages/(some-layout)/home.vue b/playground/src/pages/(some-layout)/home.vue new file mode 100644 index 000000000..f9db97c7c --- /dev/null +++ b/playground/src/pages/(some-layout)/home.vue @@ -0,0 +1,3 @@ + diff --git a/playground/typed-router.d.ts b/playground/typed-router.d.ts index 4069e9788..1ac4cdd45 100644 --- a/playground/typed-router.d.ts +++ b/playground/typed-router.d.ts @@ -18,6 +18,9 @@ declare module 'vue-router/auto-routes' { * Route name map generated by unplugin-vue-router */ export interface RouteNamedMap { + '/(some-layout)': RouteRecordInfo<'/(some-layout)', '/', Record, Record, '/(some-layout)/app' | '/(some-layout)/home'>, + '/(some-layout)/app': RouteRecordInfo<'/(some-layout)/app', '/app', Record, Record>, + '/(some-layout)/home': RouteRecordInfo<'/(some-layout)/home', '/home', Record, Record>, '/(test-group)': RouteRecordInfo<'/(test-group)', '/', Record, Record, '/(test-group)/test-group-child'>, '/(test-group)/test-group-child': RouteRecordInfo<'/(test-group)/test-group-child', '/test-group-child', Record, Record>, 'home': RouteRecordInfo<'home', '/', Record, Record>, From 2fb1afbf005df1747ae90ae021e5960c572d4976 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Sun, 29 Jun 2025 22:24:42 +0200 Subject: [PATCH 02/27] refactor: more precise isRoot --- src/core/tree.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/tree.ts b/src/core/tree.ts index 3d3fcfe43..2535811e0 100644 --- a/src/core/tree.ts +++ b/src/core/tree.ts @@ -271,7 +271,7 @@ export class TreeNode { * * @returns true if the node is the root node */ - isRoot() { + isRoot(): this is PrefixTree { return ( !this.parent && this.value.fullPath === '/' && !this.value.components.size ) From c9f6107703377b795858157b940cad2474bd4e67 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Sun, 29 Jun 2025 22:55:08 +0200 Subject: [PATCH 03/27] perf: use Intl.Collator for compare --- src/core/tree.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/core/tree.ts b/src/core/tree.ts index 2535811e0..b5672c20b 100644 --- a/src/core/tree.ts +++ b/src/core/tree.ts @@ -12,6 +12,8 @@ export interface TreeNodeOptions extends ResolvedOptions { treeNodeOptions?: TreeNodeValueOptions } +const stringCompare = new Intl.Collator('en', {}).compare + export class TreeNode { /** * value of the node @@ -142,24 +144,26 @@ export class TreeNode { } /** - * Comparator function for sorting TreeNodes by path. + * Comparator function for sorting TreeNodes. + * + * @internal */ - static compareByPath(a: TreeNode, b: TreeNode): number { - return a.path.localeCompare(b.path) + static compare(a: TreeNode, b: TreeNode): number { + return stringCompare(a.path, b.path) } /** * Get the children of this node sorted by their path. */ getSortedChildren(): TreeNode[] { - return Array.from(this.children.values()).sort(TreeNode.compareByPath) + return Array.from(this.children.values()).sort(TreeNode.compare) } /** * Calls {@link getChildrenDeep} and sorts the result by path in the end. */ getChildrenDeepSorted(): TreeNode[] { - return Array.from(this.getChildrenDeep()).sort(TreeNode.compareByPath) + return Array.from(this.getChildrenDeep()).sort(TreeNode.compare) } /** From 45de2b74692c85f35a2c3fcf25abcb8f437ed7c5 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Sun, 29 Jun 2025 22:55:32 +0200 Subject: [PATCH 04/27] feat: allow defining an empty name to remove a route from the map --- playground/src/pages/(some-layout).vue | 6 ++++++ playground/typed-router.d.ts | 1 - src/codegen/generateRouteMap.ts | 2 +- src/core/tree.ts | 11 ++++++++++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/playground/src/pages/(some-layout).vue b/playground/src/pages/(some-layout).vue index 42463140e..cf0fff14d 100644 --- a/playground/src/pages/(some-layout).vue +++ b/playground/src/pages/(some-layout).vue @@ -1,3 +1,9 @@ + +