sv-router 0.18.0 → 0.18.1

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/README.md CHANGED
@@ -21,7 +21,7 @@ Flexible, ergonomic, and complete Svelte 5 router.
21
21
 
22
22
  - 🔒 **Type-safe navigation**: Catch broken links before you ship.
23
23
  - 🗂ïļ **File-based routing (optional)**: DX of a meta-framework-like approach.
24
- - ðŸŠķ **Lightweight**: < 5kB gzipped.
24
+ - ðŸŠķ **Lightweight**: ~ 5kB gzipped.
25
25
  - ⚡ **Performance**: Built-in code splitting and preloading.
26
26
  - 🔍 **Reactive search params**: For simpler state management in the URL.
27
27
  - ðŸŒŋ **Nested routes**: Share layouts across pages.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sv-router",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "description": "Type-safe routing for Svelte SPAs",
5
5
  "keywords": [
6
6
  "router",
@@ -32,6 +32,9 @@
32
32
  "types": "./src/vite-plugin/index.d.ts"
33
33
  }
34
34
  },
35
+ "publishConfig": {
36
+ "provenance": true
37
+ },
35
38
  "dependencies": {
36
39
  "esm-env": "^1.2.2"
37
40
  },
@@ -39,16 +42,16 @@
39
42
  "@changesets/cli": "^2.31.0",
40
43
  "@eslint/js": "^10.0.1",
41
44
  "@sveltejs/vite-plugin-svelte": "^7.1.2",
42
- "@testing-library/jest-dom": "^6.9.1",
45
+ "@testing-library/jest-dom": "^7.0.0",
43
46
  "@testing-library/svelte": "^5.4.2",
44
47
  "@testing-library/user-event": "^14.6.1",
45
48
  "@types/node": "^24.13.2",
46
49
  "@vitest/coverage-v8": "^4.1.9",
47
50
  "eslint": "^10.6.0",
48
51
  "eslint-config-prettier": "^10.1.8",
49
- "eslint-plugin-simple-import-sort": "^13.0.0",
52
+ "eslint-plugin-simple-import-sort": "^14.0.0",
50
53
  "eslint-plugin-svelte": "^3.20.0",
51
- "eslint-plugin-unicorn": "^70.0.0",
54
+ "eslint-plugin-unicorn": "^72.0.0",
52
55
  "globals": "^17.7.0",
53
56
  "happy-dom": "^20.10.6",
54
57
  "oxfmt": "^0.57.0",
@@ -212,7 +212,7 @@ export function createRouterCode(routes, routesPath, { allLazy = false, base, js
212
212
  result[key] = `{ ...${varNames.toReversed().join(', ...')} }`;
213
213
  } else if (
214
214
  typeof value === 'string' &&
215
- (key === 'hooks' || key === 'meta' || (!value.endsWith('.lazy.svelte') && !allLazy))
215
+ (key === 'hooks' || key === 'meta' || (!allLazy && !value.endsWith('.lazy.svelte')))
216
216
  ) {
217
217
  const variableName = pathToCorrectCasing(value);
218
218
  importsMap.set(variableName, routesPath + value);
@@ -1,5 +1,5 @@
1
1
  import { base, location } from '../create-router.svelte.js';
2
- import { constructPath } from './utils.js';
2
+ import { constructPath, stripBase } from './utils.js';
3
3
 
4
4
  /**
5
5
  * @param {string} pathname
@@ -39,7 +39,7 @@ function compare(compareFn, pathname, params) {
39
39
  }
40
40
 
41
41
  const pathParts = pathname.split('/').slice(1);
42
- let routeParts = location.pathname.split('/').slice(1);
42
+ let routeParts = stripBase(location.pathname).split('/').slice(1);
43
43
  if (pathParts.length > routeParts.length) {
44
44
  return false;
45
45
  }
@@ -118,7 +118,7 @@ function tryMatch(route, pathParts, pathname, routes, baseMeta) {
118
118
  };
119
119
  }
120
120
  // Static segment mismatch
121
- else if (routePart.toLowerCase() !== pathPart?.toLowerCase() && !isLayoutGroup) {
121
+ else if (!isLayoutGroup && routePart.toLowerCase() !== pathPart?.toLowerCase()) {
122
122
  return null;
123
123
  }
124
124
 
@@ -49,7 +49,7 @@ export function preloadOnHover(routes) {
49
49
  /** @type {ReturnType<typeof setTimeout> | null} */
50
50
  let throttleTimer = null;
51
51
  function pointerMoveListener(/** @type {PointerEvent} */ event) {
52
- if (!event.getPredictedEvents || throttleTimer) return;
52
+ if (throttleTimer || !event.getPredictedEvents) return;
53
53
  throttleTimer = setTimeout(() => {
54
54
  throttleTimer = null;
55
55
  }, PREDICT_TIMEOUT);