@uniweb/runtime 1.3.7 → 1.3.8
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/runtime",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.8",
|
|
4
4
|
"description": "Minimal runtime for loading Uniweb foundations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"esbuild": "^0.21.0 || ^0.23.0 || ^0.24.0 || ^0.25.0 || ^0.27.0 || ^0.28.0",
|
|
45
45
|
"vite": "^7.3.1",
|
|
46
46
|
"vitest": "^4.1.7",
|
|
47
|
-
"@uniweb/build": "1.13.
|
|
47
|
+
"@uniweb/build": "1.13.11"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"react": "^19.0.0",
|
|
@@ -136,6 +136,22 @@ export function localeSwitchOf(routeHref, website) {
|
|
|
136
136
|
return { locale, route: website.reverseTranslateRoute(path, locale) }
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* The id a link's fragment names. An address percent-encodes what isn't ASCII, and an id holds it as
|
|
141
|
+
* written. ⛔ Until 2026-11-01 a link to a heading in another alphabet, from another page, found
|
|
142
|
+
* nothing to scroll to.
|
|
143
|
+
*
|
|
144
|
+
* @param {string} fragment - A fragment, without its `#`
|
|
145
|
+
* @returns {string}
|
|
146
|
+
*/
|
|
147
|
+
export function fragmentId(fragment) {
|
|
148
|
+
try {
|
|
149
|
+
return decodeURIComponent(fragment)
|
|
150
|
+
} catch {
|
|
151
|
+
return fragment
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
139
155
|
/**
|
|
140
156
|
* Scroll to element by ID with retry logic
|
|
141
157
|
* Retries a few times to handle elements that render asynchronously
|
|
@@ -176,7 +192,7 @@ export function useLinkInterceptor(options = {}) {
|
|
|
176
192
|
if (!location.hash) return
|
|
177
193
|
|
|
178
194
|
// Remove the # prefix
|
|
179
|
-
const elementId = location.hash.slice(1)
|
|
195
|
+
const elementId = fragmentId(location.hash.slice(1))
|
|
180
196
|
if (elementId) {
|
|
181
197
|
// Use requestAnimationFrame to wait for render, then scroll
|
|
182
198
|
requestAnimationFrame(() => {
|
|
@@ -217,7 +233,7 @@ export function useLinkInterceptor(options = {}) {
|
|
|
217
233
|
|
|
218
234
|
// Handle hash-only links (same page scroll)
|
|
219
235
|
if (href.startsWith('#')) {
|
|
220
|
-
const elementId = href.slice(1)
|
|
236
|
+
const elementId = fragmentId(href.slice(1))
|
|
221
237
|
if (elementId) {
|
|
222
238
|
scrollToElement(elementId)
|
|
223
239
|
// Update URL hash without navigation
|