]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
refactor: rename methods to keep same names
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 18 Sep 2025 15:13:44 +0000 (17:13 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 18 Sep 2025 15:13:44 +0000 (17:13 +0200)
packages/router/package.json
packages/router/src/experimental/route-resolver/matchers/matcher-pattern.ts
packages/router/src/experimental/route-resolver/matchers/param-parsers/types.ts
packages/router/src/experimental/route-resolver/resolver-abstract.ts
packages/router/src/experimental/route-resolver/resolver-fixed.ts
packages/router/src/experimental/router.ts
pnpm-lock.yaml

index f2e9c5a47681374d5ddc9aa497ac33284d979a8b..13a5e1c907749a294c4aeea82bc7be17a5d3cc63 100644 (file)
     "@vue/devtools-api": "^6.6.4"
   },
   "devDependencies": {
-    "@microsoft/api-extractor": "^7.52.11",
-    "@rollup/plugin-alias": "^5.1.1",
     "@rollup/plugin-commonjs": "^25.0.8",
     "@rollup/plugin-node-resolve": "^15.3.1",
     "@rollup/plugin-replace": "^5.0.7",
     "nightwatch-helpers": "^1.2.0",
     "rimraf": "^6.0.1",
     "rollup": "^3.29.5",
-    "rollup-plugin-analyzer": "^4.0.0",
     "rollup-plugin-typescript2": "^0.36.0",
     "tsdown": "^0.12.9",
     "tsup": "^8.5.0",
index e0f804adc240f95a02f665885e70f98d88ee4aa8..af7f0463e5f32cb5cd5716ddfc977bfa4553378a 100644 (file)
@@ -10,9 +10,12 @@ import type { Simplify } from '../../../types/utils'
  *
  * @template TIn - type of the input value to match against the pattern
  * @template TParams - type of the output value after matching
+ * @template TParamsRaw - type of the input value to build the input from
  *
  * In the case of the `path`, the `TIn` is a `string`, but in the case of the
- * query, it's the object of query params.
+ * query, it's the object of query params. `TParamsRaw` allows for a more permissive
+ * type when building the value, for example allowing numbers and strings like
+ * the old params.
  *
  * @internal this is the base interface for all matcher patterns, it shouldn't
  * be used directly
index 0c6b1d9dddfd8efb0e4c54c1ee7b2cc240d08337..6d4790301e5a8ff09849b6a1dcb80436c06e1521 100644 (file)
@@ -14,7 +14,7 @@ export interface ParamParser<
   // not allow `null` within an array or `undefined`)
   TUrlParam = MatcherQueryParamsValue,
   // the type that can be passed as a location when navigating: `router.push({ params: { }})`
-  // it's sometimes for more permissive than TParam, for example allowing nullish values
+  // it's sometimes more permissive than TParam, for example allowing nullish values
   TParamRaw = TParam,
 > {
   get?: (value: NoInfer<TUrlParam>) => TParam
index 106f5e016d40c09d3ce895607c02589c3b280fc8..84ed80ef83a3282ef66affa4a0da294d555a1b54 100644 (file)
@@ -14,7 +14,7 @@ export type RecordName = string | symbol
  * serialization of params, query, and hash.
  *
  * - `TMatcherRecordRaw` represents the raw record type passed to {@link addMatcher}.
- * - `TMatcherRecord` represents the normalized record type returned by {@link getRecords}.
+ * - `TMatcherRecord` represents the normalized record type returned by {@link getRoutes}.
  */
 export interface EXPERIMENTAL_Resolver_Base<TRecord> {
   /**
@@ -44,7 +44,7 @@ export interface EXPERIMENTAL_Resolver_Base<TRecord> {
    */
   resolve(
     location: ResolverLocationAsNamed,
-    // TODO: is this useful?
+    // TODO: is this type strictness useful?
     currentLocation?: undefined
     // currentLocation?: undefined | NEW_LocationResolved<TMatcherRecord>
   ): ResolverLocationResolved<TRecord>
@@ -78,16 +78,15 @@ export interface EXPERIMENTAL_Resolver_Base<TRecord> {
   ): ResolverLocationResolved<TRecord>
 
   /**
-   * Get a list of all resolver records.
-   * Previously named `getRoutes()`
+   * Get a list of all resolver route records.
    */
-  getRecords(): TRecord[]
+  getRoutes(): TRecord[]
 
   /**
    * Get a resolver record by its name.
    * Previously named `getRecordMatcher()`
    */
-  getRecord(name: RecordName): TRecord | undefined
+  getRoute(name: RecordName): TRecord | undefined
 }
 
 /**
index 13bdb30b67a42edb84f5caa1eabb92eadc66cb3b..145298acbb217e5831e38b5c8a4705af37240d73 100644 (file)
@@ -65,6 +65,9 @@ export interface EXPERIMENTAL_ResolverRecord_Base {
  */
 export interface EXPERIMENTAL_ResolverRecord_Group
   extends EXPERIMENTAL_ResolverRecord_Base {
+  /**
+   * A group route cannot be matched directly and so names are not allowed.
+   */
   name?: undefined
   path?: undefined
   // Query is the only kind of matcher that is non-exclusive
@@ -74,7 +77,8 @@ export interface EXPERIMENTAL_ResolverRecord_Group
 }
 
 /**
- * A matchable record is a record that can be matched by a path, query or hash and will resolve to a location.
+ * A matchable record is a record that can be matched by a path, query or hash
+ * and will resolve to a location.
  */
 export interface EXPERIMENTAL_ResolverRecord_Matchable
   extends EXPERIMENTAL_ResolverRecord_Base {
@@ -324,7 +328,7 @@ export function createFixedResolver<
 
   return {
     resolve,
-    getRecords: () => records,
-    getRecord: name => recordMap.get(name),
+    getRoutes: () => records,
+    getRoute: name => recordMap.get(name),
   }
 }
index b5db8b0e08459d4f38f0517a11f987a2acad677f..7e5d2c72f4f9e48c9765dd67303d936135f08472 100644 (file)
@@ -390,6 +390,10 @@ export interface EXPERIMENTAL_RouterOptions
   resolver: EXPERIMENTAL_ResolverFixed<EXPERIMENTAL_RouteRecordNormalized_Matchable>
 }
 
+// TODO: Make the Router extends the resolver so that it automatically exposes
+// getRoutes and resolve. This should make it automatic to have a dynamic
+// resolver
+
 /**
  * Router base instance.
  *
@@ -614,14 +618,6 @@ export function experimental_createRouter(
     history.scrollRestoration = 'manual'
   }
 
-  function getRoutes() {
-    return resolver.getRecords()
-  }
-
-  function hasRoute(name: NonNullable<RouteRecordNameGeneric>): boolean {
-    return !!resolver.getRecord(name)
-  }
-
   // NOTE: to support multiple overloads
   type TRecord = EXPERIMENTAL_RouteRecordNormalized
   type _resolveArgs =
@@ -1290,8 +1286,8 @@ export function experimental_createRouter(
     currentRoute,
     listening: true,
 
-    hasRoute,
-    getRoutes,
+    hasRoute: name => !!resolver.getRoute(name),
+    getRoutes: () => resolver.getRoutes(),
     // @ts-expect-error FIXME: update EXPERIMENTAL_Router types
     resolve,
     options,
index 4019bdbafee02b7a5f00e7f51a430f7a43559188..5638131b1631fe196c09579b55bab4416be74f2c 100644 (file)
@@ -146,12 +146,6 @@ importers:
         specifier: ^6.6.4
         version: 6.6.4
     devDependencies:
-      '@microsoft/api-extractor':
-        specifier: ^7.52.11
-        version: 7.52.11(@types/node@24.3.0)
-      '@rollup/plugin-alias':
-        specifier: ^5.1.1
-        version: 5.1.1(rollup@3.29.5)
       '@rollup/plugin-commonjs':
         specifier: ^25.0.8
         version: 25.0.8(rollup@3.29.5)
@@ -221,9 +215,6 @@ importers:
       rollup:
         specifier: ^3.29.5
         version: 3.29.5
-      rollup-plugin-analyzer:
-        specifier: ^4.0.0
-        version: 4.0.0
       rollup-plugin-typescript2:
         specifier: ^0.36.0
         version: 0.36.0(rollup@3.29.5)(typescript@5.8.3)
@@ -1025,15 +1016,6 @@ packages:
   '@rolldown/pluginutils@1.0.0-beta.29':
     resolution: {integrity: sha512-NIJgOsMjbxAXvoGq/X0gD7VPMQ8j9g0BiDaNjVNVjvl+iKXxL3Jre0v31RmBYeLEmkbj2s02v8vFTbUXi5XS2Q==}
 
-  '@rollup/plugin-alias@5.1.1':
-    resolution: {integrity: sha512-PR9zDb+rOzkRb2VD+EuKB7UC41vU5DIwZ5qqCpk0KJudcWAyi8rvYOhS7+L5aZCspw1stTViLgN5v6FF1p5cgQ==}
-    engines: {node: '>=14.0.0'}
-    peerDependencies:
-      rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0
-    peerDependenciesMeta:
-      rollup:
-        optional: true
-
   '@rollup/plugin-commonjs@25.0.8':
     resolution: {integrity: sha512-ZEZWTK5n6Qde0to4vS9Mr5x/0UZoqCxPVR9KRUjU4kA2sO7GEUn1fop0DAwpO6z0Nw/kJON9bDmSxdWxO/TT1A==}
     engines: {node: '>=14.0.0'}
@@ -4142,10 +4124,6 @@ packages:
     resolution: {integrity: sha512-QOANlVluwwrLP5snQqKfC2lv/KJphMkjh4V0gpw0K40GdKmhd8eShIGOJNAC51idk5cn3xI08SZTRWj0R2XlDw==}
     hasBin: true
 
-  rollup-plugin-analyzer@4.0.0:
-    resolution: {integrity: sha512-LL9GEt3bkXp6Wa19SNR5MWcvHNMvuTFYg+eYBZN2OIFhSWN+pEJUQXEKu5BsOeABob3x9PDaLKW7w5iOJnsESQ==}
-    engines: {node: '>=8.0.0'}
-
   rollup-plugin-typescript2@0.36.0:
     resolution: {integrity: sha512-NB2CSQDxSe9+Oe2ahZbf+B4bh7pHwjV5L+RSYpCu7Q5ROuN94F9b6ioWwKfz3ueL3KTtmX4o2MUH2cgHDIEUsw==}
     peerDependencies:
@@ -5690,11 +5668,13 @@ snapshots:
 
   '@iconify/types@2.0.0': {}
 
-  '@isaacs/balanced-match@4.0.1': {}
+  '@isaacs/balanced-match@4.0.1':
+    optional: true
 
   '@isaacs/brace-expansion@5.0.0':
     dependencies:
       '@isaacs/balanced-match': 4.0.1
+    optional: true
 
   '@isaacs/cliui@8.0.2':
     dependencies:
@@ -5741,6 +5721,7 @@ snapshots:
       '@rushstack/node-core-library': 5.14.0(@types/node@24.3.0)
     transitivePeerDependencies:
       - '@types/node'
+    optional: true
 
   '@microsoft/api-extractor@7.52.11(@types/node@24.3.0)':
     dependencies:
@@ -5759,6 +5740,7 @@ snapshots:
       typescript: 5.8.2
     transitivePeerDependencies:
       - '@types/node'
+    optional: true
 
   '@microsoft/tsdoc-config@0.17.1':
     dependencies:
@@ -5766,8 +5748,10 @@ snapshots:
       ajv: 8.12.0
       jju: 1.4.0
       resolve: 1.22.8
+    optional: true
 
-  '@microsoft/tsdoc@0.15.1': {}
+  '@microsoft/tsdoc@0.15.1':
+    optional: true
 
   '@napi-rs/wasm-runtime@1.0.0':
     dependencies:
@@ -5862,10 +5846,6 @@ snapshots:
 
   '@rolldown/pluginutils@1.0.0-beta.29': {}
 
-  '@rollup/plugin-alias@5.1.1(rollup@3.29.5)':
-    optionalDependencies:
-      rollup: 3.29.5
-
   '@rollup/plugin-commonjs@25.0.8(rollup@3.29.5)':
     dependencies:
       '@rollup/pluginutils': 5.1.0(rollup@3.29.5)
@@ -6109,11 +6089,13 @@ snapshots:
       semver: 7.5.4
     optionalDependencies:
       '@types/node': 24.3.0
+    optional: true
 
   '@rushstack/rig-package@0.5.3':
     dependencies:
       resolve: 1.22.8
       strip-json-comments: 3.1.1
+    optional: true
 
   '@rushstack/terminal@0.15.4(@types/node@24.3.0)':
     dependencies:
@@ -6121,6 +6103,7 @@ snapshots:
       supports-color: 8.1.1
     optionalDependencies:
       '@types/node': 24.3.0
+    optional: true
 
   '@rushstack/ts-command-line@5.0.2(@types/node@24.3.0)':
     dependencies:
@@ -6130,6 +6113,7 @@ snapshots:
       string-argv: 0.3.2
     transitivePeerDependencies:
       - '@types/node'
+    optional: true
 
   '@sec-ant/readable-stream@0.4.1': {}
 
@@ -6208,7 +6192,8 @@ snapshots:
       tslib: 2.8.1
     optional: true
 
-  '@types/argparse@1.0.38': {}
+  '@types/argparse@1.0.38':
+    optional: true
 
   '@types/chai@4.3.16': {}
 
@@ -6694,10 +6679,12 @@ snapshots:
   ajv-draft-04@1.0.0(ajv@8.13.0):
     optionalDependencies:
       ajv: 8.13.0
+    optional: true
 
   ajv-formats@3.0.1(ajv@8.13.0):
     optionalDependencies:
       ajv: 8.13.0
+    optional: true
 
   ajv@8.12.0:
     dependencies:
@@ -6705,6 +6692,7 @@ snapshots:
       json-schema-traverse: 1.0.0
       require-from-string: 2.0.2
       uri-js: 4.4.1
+    optional: true
 
   ajv@8.13.0:
     dependencies:
@@ -6712,6 +6700,7 @@ snapshots:
       json-schema-traverse: 1.0.0
       require-from-string: 2.0.2
       uri-js: 4.4.1
+    optional: true
 
   algoliasearch@5.34.0:
     dependencies:
@@ -6773,6 +6762,7 @@ snapshots:
   argparse@1.0.10:
     dependencies:
       sprintf-js: 1.0.3
+    optional: true
 
   argparse@2.0.1: {}
 
@@ -7543,7 +7533,8 @@ snapshots:
 
   faked-promise@2.2.2: {}
 
-  fast-deep-equal@3.1.3: {}
+  fast-deep-equal@3.1.3:
+    optional: true
 
   fast-fifo@1.3.2: {}
 
@@ -7662,6 +7653,7 @@ snapshots:
       graceful-fs: 4.2.11
       jsonfile: 6.2.0
       universalify: 2.0.1
+    optional: true
 
   fs.realpath@1.0.0: {}
 
@@ -7947,7 +7939,8 @@ snapshots:
 
   immediate@3.0.6: {}
 
-  import-lazy@4.0.0: {}
+  import-lazy@4.0.0:
+    optional: true
 
   indent-string@4.0.0: {}
 
@@ -8099,7 +8092,8 @@ snapshots:
 
   jiti@2.4.2: {}
 
-  jju@1.4.0: {}
+  jju@1.4.0:
+    optional: true
 
   joycon@3.1.1: {}
 
@@ -8189,7 +8183,8 @@ snapshots:
 
   json-parse-even-better-errors@2.3.1: {}
 
-  json-schema-traverse@1.0.0: {}
+  json-schema-traverse@1.0.0:
+    optional: true
 
   json-stringify-safe@5.0.1: {}
 
@@ -8206,6 +8201,7 @@ snapshots:
       universalify: 2.0.1
     optionalDependencies:
       graceful-fs: 4.2.11
+    optional: true
 
   jsonparse@1.3.1: {}
 
@@ -8487,6 +8483,7 @@ snapshots:
   minimatch@10.0.3:
     dependencies:
       '@isaacs/brace-expansion': 5.0.0
+    optional: true
 
   minimatch@3.1.2:
     dependencies:
@@ -9007,7 +9004,8 @@ snapshots:
 
   require-directory@2.1.1: {}
 
-  require-from-string@2.0.2: {}
+  require-from-string@2.0.2:
+    optional: true
 
   requires-port@1.0.0: {}
 
@@ -9091,8 +9089,6 @@ snapshots:
       '@rolldown/binding-win32-ia32-msvc': 1.0.0-beta.28
       '@rolldown/binding-win32-x64-msvc': 1.0.0-beta.28
 
-  rollup-plugin-analyzer@4.0.0: {}
-
   rollup-plugin-typescript2@0.36.0(rollup@3.29.5)(typescript@5.8.3):
     dependencies:
       '@rollup/pluginutils': 4.2.1
@@ -9234,6 +9230,7 @@ snapshots:
   semver@7.5.4:
     dependencies:
       lru-cache: 6.0.0
+    optional: true
 
   semver@7.7.1: {}
 
@@ -9366,7 +9363,8 @@ snapshots:
     dependencies:
       through: 2.3.8
 
-  sprintf-js@1.0.3: {}
+  sprintf-js@1.0.3:
+    optional: true
 
   sprintf-js@1.1.3: {}
 
@@ -9704,7 +9702,8 @@ snapshots:
       typescript: 5.8.3
       yaml: 2.8.0
 
-  typescript@5.8.2: {}
+  typescript@5.8.2:
+    optional: true
 
   typescript@5.8.3: {}
 
@@ -9766,6 +9765,7 @@ snapshots:
   uri-js@4.4.1:
     dependencies:
       punycode: 2.3.1
+    optional: true
 
   url-parse@1.5.10:
     dependencies: