Skip to content

Commit 648f17d

Browse files
committed
refactor: adapt to new version
1 parent 9877034 commit 648f17d

File tree

5 files changed

+40
-28
lines changed

5 files changed

+40
-28
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
"vitepress-plugin-llms": "^1.7.5",
204204
"vitest": "^3.2.4",
205205
"vue": "^3.5.21",
206-
"vue-router": "https://pkg.pr.new/vue-router@3646b9c",
206+
"vue-router": "https://pkg.pr.new/vue-router@be1679c",
207207
"vue-router-mock": "^2.0.0",
208208
"vue-tsc": "^3.0.7",
209209
"vuefire": "^3.2.2",

playground-experimental/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
"mande": "^2.0.9",
1919
"pinia": "^3.0.3",
2020
"vue": "^3.5.18",
21-
"vue-router": "https://pkg.pr.new/vue-router@3646b9c"
21+
"vue-router": "https://pkg.pr.new/vue-router@be1679c"
2222
}
2323
}

pnpm-lock.yaml

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/codegen/generateParamParsers.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ export function generateParamParserOptions(
6666
const { name, absolutePath } = paramParsers.get(param.parser)!
6767
const varName = `PARAM_PARSER__${name}`
6868
importsMap.add(absolutePath, { name: 'parser', as: varName })
69-
return ` ...${varName}, `
69+
return varName
7070
} else if (param.parser === 'int') {
7171
importsMap.add('vue-router/experimental', `PARAM_PARSER_INT`)
72-
// the path params have more options, the query params are passed as an argument
73-
return 'modifier' in param ? ` ...PARAM_PARSER_INT, ` : `PARAM_PARSER_INT`
72+
return `PARAM_PARSER_INT`
7473
}
7574
return ''
7675
}
@@ -81,9 +80,22 @@ export function generatePathParamsOptions(
8180
paramParsers: ParamParsersMap
8281
) {
8382
const paramOptions = params.map((param) => {
84-
const repeatable = param.repeatable ? `repeat: true, ` : ''
83+
// build a lean option list without any optional value
84+
const optionList: string[] = []
85+
const parser = generateParamParserOptions(param, importsMap, paramParsers)
86+
optionList.push(parser || `/* no parser */`)
87+
if (param.optional || param.repeatable) {
88+
optionList.push(
89+
`/* repeatable: ` + (param.repeatable ? `*/ true` : `false */`)
90+
)
91+
}
92+
if (param.optional) {
93+
optionList.push(
94+
`/* optional: ` + (param.optional ? `*/ true` : `false */`)
95+
)
96+
}
8597
return `
86-
${param.paramName}: {${generateParamParserOptions(param, importsMap, paramParsers)}${repeatable}},
98+
${param.paramName}: [${optionList.join(', ')}],
8799
`.slice(1, -1)
88100
})
89101

src/codegen/generateRouteResolver.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('generateRouteRecordPath', () => {
6060
"path: new MatcherPatternPathDynamic(
6161
/^\\/a\\/([^/]+?)$/i,
6262
{
63-
b: {},
63+
b: [/* no parser */],
6464
},
6565
["a",1],
6666
),"
@@ -79,8 +79,8 @@ describe('generateRouteRecordPath', () => {
7979
"path: new MatcherPatternPathDynamic(
8080
/^\\/a\\/([^/]+?)\\/([^/]+?)$/i,
8181
{
82-
b: {},
83-
c: {},
82+
b: [/* no parser */],
83+
c: [/* no parser */],
8484
},
8585
["a",1,1],
8686
),"
@@ -95,7 +95,7 @@ describe('generateRouteRecordPath', () => {
9595
"path: new MatcherPatternPathDynamic(
9696
/^\\/a\\/([^/]+?)?$/i,
9797
{
98-
b: {},
98+
b: [/* no parser */, /* repeatable: false */, /* optional: */ true],
9999
},
100100
["a",1],
101101
),"
@@ -110,7 +110,7 @@ describe('generateRouteRecordPath', () => {
110110
"path: new MatcherPatternPathDynamic(
111111
/^\\/a\\/(.+?)$/i,
112112
{
113-
b: {repeat: true, },
113+
b: [/* no parser */, /* repeatable: */ true],
114114
},
115115
["a",1],
116116
),"
@@ -125,7 +125,7 @@ describe('generateRouteRecordPath', () => {
125125
"path: new MatcherPatternPathDynamic(
126126
/^\\/a\\/(.+?)?$/i,
127127
{
128-
b: {repeat: true, },
128+
b: [/* no parser */, /* repeatable: */ true, /* optional: */ true],
129129
},
130130
["a",1],
131131
),"
@@ -143,8 +143,8 @@ describe('generateRouteRecordPath', () => {
143143
"path: new MatcherPatternPathDynamic(
144144
/^\\/a\\/a-([^/]+?)-c-([^/]+?)$/i,
145145
{
146-
b: {},
147-
d: {},
146+
b: [/* no parser */],
147+
d: [/* no parser */],
148148
},
149149
["a",["a-",0,"-c-",0]],
150150
),"
@@ -162,7 +162,7 @@ describe('generateRouteRecordPath', () => {
162162
"path: new MatcherPatternPathDynamic(
163163
/^\\/(.*)$/i,
164164
{
165-
all: {},
165+
all: [/* no parser */],
166166
},
167167
[0],
168168
),"
@@ -180,8 +180,8 @@ describe('generateRouteRecordPath', () => {
180180
"path: new MatcherPatternPathDynamic(
181181
/^\\/a\\/some-([^/]+?)\\/(.*)$/i,
182182
{
183-
id: {},
184-
all: {},
183+
id: [/* no parser */],
184+
all: [/* no parser */],
185185
},
186186
["a",["some-",0],0],
187187
),"

0 commit comments

Comments
 (0)