1+ import { parse_route_id } from '../../utils/routing.js' ;
12import { write_if_changed } from './utils.js' ;
23
34/** @param {string } imports */
@@ -24,21 +25,6 @@ export function write_types(config, manifest_data) {
2425 /** @type {Map<string, { params: string[], type: 'page' | 'endpoint' | 'both' }> } */
2526 const shadow_types = new Map ( ) ;
2627
27- /** @param {string } key */
28- function extract_params ( key ) {
29- /** @type {string[] } */
30- const params = [ ] ;
31-
32- const pattern = / \[ (?: \. { 3 } ) ? ( [ ^ \] ] + ) \] / g;
33- let match ;
34-
35- while ( ( match = pattern . exec ( key ) ) ) {
36- params . push ( match [ 1 ] ) ;
37- }
38-
39- return params ;
40- }
41-
4228 manifest_data . routes . forEach ( ( route ) => {
4329 const file = route . type === 'endpoint' ? route . file : route . shadow ;
4430
@@ -48,7 +34,7 @@ export function write_types(config, manifest_data) {
4834 ) ;
4935 const key = file . slice ( 0 , - ext . length ) ;
5036 shadow_types . set ( key , {
51- params : extract_params ( key ) ,
37+ params : parse_route_id ( key ) . names ,
5238 type : route . type === 'endpoint' ? 'endpoint' : 'both'
5339 } ) ;
5440 }
@@ -61,7 +47,7 @@ export function write_types(config, manifest_data) {
6147 const key = component . slice ( 0 , - ext . length ) ;
6248
6349 if ( ! shadow_types . has ( key ) ) {
64- shadow_types . set ( key , { params : extract_params ( key ) , type : 'page' } ) ;
50+ shadow_types . set ( key , { params : parse_route_id ( key ) . names , type : 'page' } ) ;
6551 }
6652 } ) ;
6753
0 commit comments