@vesk/runtime 0.2.50 → 0.2.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/router-match.d.ts +6 -0
- package/dist/router-match.d.ts.map +1 -1
- package/dist/router-match.js +53 -1
- package/package.json +2 -2
package/dist/router-match.d.ts
CHANGED
|
@@ -23,6 +23,12 @@ export interface RouteNode {
|
|
|
23
23
|
export interface RouteMatch {
|
|
24
24
|
matchChain: RouteNode[];
|
|
25
25
|
params: Record<string, string>;
|
|
26
|
+
/**
|
|
27
|
+
* The pathname this match was computed FOR — not the pattern that matched.
|
|
28
|
+
* `usePathname()` and `NavLink`'s active state read it, so leaving it unset
|
|
29
|
+
* made every route report `/` (via `pathname || ''`), which is what made
|
|
30
|
+
* NavLink highlighting permanently inert.
|
|
31
|
+
*/
|
|
26
32
|
pathname?: string;
|
|
27
33
|
}
|
|
28
34
|
interface CompiledRoute {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-match.d.ts","sourceRoot":"","sources":["../src/router-match.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACvB,MAAM,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACzB,OAAO,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B,OAAO,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAAC;IACnC,OAAO,CAAC,EAAE,QAAQ,GAA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AE,CAAC;CACrB;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAiBnE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,EAAE,CA6B/G;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAO5E;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAc1F;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,MAAM,GAAE,SAAS,EAAO,GAAG,SAAS,EAAE,CAqFhH;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAwBjF;AAED,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAChC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,SAAS,EAAE,CA0Bb"}
|
package/dist/router-match.js
CHANGED
|
@@ -82,7 +82,44 @@ export function flattenLayoutChain(tree, pathParts, result = []) {
|
|
|
82
82
|
for (let i = 0; i < tree.length; i++) {
|
|
83
83
|
const node = tree[i];
|
|
84
84
|
if (node.isGroup) {
|
|
85
|
+
// A group contributes its LAYOUT to every route beneath it, so it has
|
|
86
|
+
// to be in the chain even when one of its children is the match.
|
|
87
|
+
// Dropping it meant `app/(public)/layout.vsk` never applied on the
|
|
88
|
+
// client — the framework's own hyd-dbg output showed
|
|
89
|
+
// `layoutNames:["Layout_Index"]` for `/about`, i.e. the root layout
|
|
90
|
+
// only, and the page rendered outside its shell. SSR kept the group
|
|
91
|
+
// (the server routes from the build manifest), which is why the page
|
|
92
|
+
// looked right until the client took over.
|
|
93
|
+
//
|
|
94
|
+
// A group consumes no path segment, so children are matched against
|
|
95
|
+
// the SAME parts.
|
|
96
|
+
const contributes = !!(node.layout || node.page);
|
|
97
|
+
const marker = result.length;
|
|
98
|
+
if (contributes)
|
|
99
|
+
result.push(node);
|
|
100
|
+
const before = result.length;
|
|
85
101
|
flattenLayoutChain(node.children || [], pathParts, result);
|
|
102
|
+
if (result.length > before)
|
|
103
|
+
break;
|
|
104
|
+
// No child matched at this position; if the group is not itself the
|
|
105
|
+
// page here, it contributes nothing and must not stay in the chain.
|
|
106
|
+
// (If it IS the page, the push above is the match.)
|
|
107
|
+
if (contributes)
|
|
108
|
+
result.length = marker;
|
|
109
|
+
// A group can BE the page at this position: `app/(public)/page.vsk`
|
|
110
|
+
// serves `/`. Recursing into its children was the only thing this
|
|
111
|
+
// branch did, and at `/` none of them match (each carries a path
|
|
112
|
+
// segment), so the group was dropped and the chain collapsed onto the
|
|
113
|
+
// page-less root — a client-side 404 for the zero-segment path, with
|
|
114
|
+
// no hydration, while `/about` and every nested route matched fine.
|
|
115
|
+
//
|
|
116
|
+
// A group is transparent for prefix matching; it has to be
|
|
117
|
+
// transparent here too. Only at a terminal position: mid-path, the
|
|
118
|
+
// child that matched is the page, not the group.
|
|
119
|
+
if (node.page && (pathParts.length === 0 || pathParts.every((p) => p === ''))) {
|
|
120
|
+
result.push(node);
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
86
123
|
continue;
|
|
87
124
|
}
|
|
88
125
|
const part = pathParts[0];
|
|
@@ -108,6 +145,21 @@ export function flattenLayoutChain(tree, pathParts, result = []) {
|
|
|
108
145
|
result.length = 0;
|
|
109
146
|
result.push(node);
|
|
110
147
|
if (isLeaf) {
|
|
148
|
+
// A container node at a terminal position must still let a deeper
|
|
149
|
+
// page-owning node win. The root is exactly this case: it matches
|
|
150
|
+
// every URL, so without descending here the chain stopped on the
|
|
151
|
+
// page-less root and never reached `app/(public)/page.vsk` — a
|
|
152
|
+
// client 404 with no hydration for `/`, while `/about` matched
|
|
153
|
+
// fine.
|
|
154
|
+
//
|
|
155
|
+
// Only when THIS node has no page of its own; if it does, it is the
|
|
156
|
+
// page and descending would shadow it.
|
|
157
|
+
if (!node.page && (node.children || []).length > 0) {
|
|
158
|
+
const before = result.length;
|
|
159
|
+
flattenLayoutChain(node.children || [], remaining, result);
|
|
160
|
+
if (result.length > before)
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
111
163
|
break;
|
|
112
164
|
}
|
|
113
165
|
else if ((node.children || []).length > 0) {
|
|
@@ -140,7 +192,7 @@ export function matchRoute(tree, pathname) {
|
|
|
140
192
|
}
|
|
141
193
|
partIdx += segCount;
|
|
142
194
|
}
|
|
143
|
-
return { matchChain, params };
|
|
195
|
+
return { matchChain, params, pathname };
|
|
144
196
|
}
|
|
145
197
|
export function buildTreeFromMap(routes, _options) {
|
|
146
198
|
const root = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/runtime",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.52",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vesk runtime — reactivity, blocks, DOM operations, hydration",
|
|
6
6
|
"main": "./dist/index-client.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@vesk/compiler": "^0.2.
|
|
54
|
+
"@vesk/compiler": "^0.2.52"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"typecheck": "tsc --noEmit",
|