sv-router 0.16.1 → 0.16.3
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,21 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sv-router",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.3",
|
|
4
4
|
"description": "Type-safe routing for Svelte SPAs",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"svelte",
|
|
7
6
|
"router",
|
|
8
|
-
"spa"
|
|
7
|
+
"spa",
|
|
8
|
+
"svelte"
|
|
9
9
|
],
|
|
10
10
|
"homepage": "https://github.com/colinlienard/sv-router",
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/colinlienard/sv-router/issues"
|
|
13
13
|
},
|
|
14
|
+
"license": "MIT",
|
|
14
15
|
"repository": {
|
|
15
16
|
"type": "git",
|
|
16
17
|
"url": "git+https://github.com/colinlienard/sv-router.git"
|
|
17
18
|
},
|
|
18
|
-
"
|
|
19
|
+
"files": [
|
|
20
|
+
"src"
|
|
21
|
+
],
|
|
19
22
|
"type": "module",
|
|
20
23
|
"exports": {
|
|
21
24
|
".": {
|
|
@@ -28,9 +31,6 @@
|
|
|
28
31
|
"types": "./src/vite-plugin/index.d.ts"
|
|
29
32
|
}
|
|
30
33
|
},
|
|
31
|
-
"files": [
|
|
32
|
-
"src"
|
|
33
|
-
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"esm-env": "^1.2.2"
|
|
36
36
|
},
|
|
@@ -41,24 +41,22 @@
|
|
|
41
41
|
"@testing-library/jest-dom": "^6.9.1",
|
|
42
42
|
"@testing-library/svelte": "^5.3.1",
|
|
43
43
|
"@testing-library/user-event": "^14.6.1",
|
|
44
|
-
"@types/node": "^24.12.
|
|
45
|
-
"@vitest/coverage-v8": "^4.1.
|
|
46
|
-
"eslint": "^10.
|
|
44
|
+
"@types/node": "^24.12.4",
|
|
45
|
+
"@vitest/coverage-v8": "^4.1.7",
|
|
46
|
+
"eslint": "^10.4.0",
|
|
47
47
|
"eslint-config-prettier": "^10.1.8",
|
|
48
48
|
"eslint-plugin-simple-import-sort": "^13.0.0",
|
|
49
|
-
"eslint-plugin-svelte": "^3.
|
|
49
|
+
"eslint-plugin-svelte": "^3.18.0",
|
|
50
50
|
"eslint-plugin-unicorn": "^64.0.0",
|
|
51
51
|
"globals": "^17.6.0",
|
|
52
52
|
"happy-dom": "^20.9.0",
|
|
53
|
-
"
|
|
54
|
-
"prettier-plugin-jsdoc": "^1.8.0",
|
|
55
|
-
"prettier-plugin-svelte": "^3.5.1",
|
|
53
|
+
"oxfmt": "^0.52.0",
|
|
56
54
|
"svelte-check": "^4.4.8",
|
|
57
55
|
"type-testing": "^0.2.0",
|
|
58
56
|
"typescript": "^6.0.3",
|
|
59
|
-
"typescript-eslint": "^8.
|
|
60
|
-
"vite": "^8.0.
|
|
61
|
-
"vitest": "^4.1.
|
|
57
|
+
"typescript-eslint": "^8.60.0",
|
|
58
|
+
"vite": "^8.0.14",
|
|
59
|
+
"vitest": "^4.1.7"
|
|
62
60
|
},
|
|
63
61
|
"peerDependencies": {
|
|
64
62
|
"svelte": "^5"
|
|
@@ -74,8 +72,8 @@
|
|
|
74
72
|
"check": "svelte-check && pnpm -r check",
|
|
75
73
|
"lint": "eslint . --max-warnings 0",
|
|
76
74
|
"lint:fix": "eslint . --fix",
|
|
77
|
-
"format": "
|
|
78
|
-
"format:fix": "
|
|
75
|
+
"format": "oxfmt --check",
|
|
76
|
+
"format:fix": "oxfmt",
|
|
79
77
|
"changeset": "changeset"
|
|
80
78
|
},
|
|
81
79
|
"bin": {
|
|
@@ -229,8 +229,9 @@ export async function onNavigate(path, options = {}) {
|
|
|
229
229
|
const matchPath = getMatchPath(path);
|
|
230
230
|
const { match, layouts, hooks, meta: newMeta, params: newParams } = matchRoute(matchPath, routes);
|
|
231
231
|
|
|
232
|
-
const
|
|
233
|
-
const
|
|
232
|
+
const navContext = path ? options : { ...options, ...updatedLocation() };
|
|
233
|
+
const search = parseSearch(navContext.search);
|
|
234
|
+
const hooksContext = { ...navContext, pathname: matchPath, meta: newMeta, search };
|
|
234
235
|
|
|
235
236
|
let errorHooks = [];
|
|
236
237
|
for (const hook of hooks) {
|
|
@@ -345,6 +346,8 @@ export function onGlobalClick(event) {
|
|
|
345
346
|
const path = base.name === '#' ? url.hash : url.pathname;
|
|
346
347
|
const hash = base.name === '#' ? undefined : url.hash;
|
|
347
348
|
|
|
349
|
+
if (base.name && base.name !== '#' && !path.startsWith(base.name)) return;
|
|
350
|
+
|
|
348
351
|
event.preventDefault();
|
|
349
352
|
const { replace, state, scrollToTop, viewTransition } = anchor.dataset;
|
|
350
353
|
|
|
@@ -66,8 +66,11 @@ export function syncSearchParams(search) {
|
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
const newSearch = new URLSearchParams(search);
|
|
69
|
-
for (const
|
|
70
|
-
searchParams.
|
|
69
|
+
for (const key of newSearch.keys()) {
|
|
70
|
+
searchParams.delete(key);
|
|
71
|
+
for (const value of newSearch.getAll(key)) {
|
|
72
|
+
searchParams.append(key, value);
|
|
73
|
+
}
|
|
71
74
|
}
|
|
72
75
|
// eslint-disable-next-line unicorn/no-useless-spread
|
|
73
76
|
for (const key of [...searchParams.keys()]) {
|