@@ -2,7 +2,7 @@ import { camelize } from '@vue/shared';
22import type { ScriptSetupRanges } from '../../parsers/scriptSetupRanges' ;
33import type { Code , Sfc , TextRange } from '../../types' ;
44import { codeFeatures } from '../codeFeatures' ;
5- import { endOfLine , generatePartiallyEnding , generateSfcBlockSection , identifierRegex , newLine } from '../utils' ;
5+ import { endOfLine , generateSfcBlockSection , identifierRegex , newLine } from '../utils' ;
66import { endBoundary , startBoundary } from '../utils/boundary' ;
77import { generateCamelized } from '../utils/camelized' ;
88import { type CodeTransform , generateCodeWithTransforms , insert , replace } from '../utils/transform' ;
@@ -33,7 +33,7 @@ export function* generateScriptSetup(
3333 scriptSetupRanges : ScriptSetupRanges ,
3434) : Generator < Code > {
3535 if ( scriptSetup . generic ) {
36- yield * generateConstExport ( options , scriptSetup ) ;
36+ yield * generateConstExport ( scriptSetup ) ;
3737 yield `(` ;
3838 if ( typeof scriptSetup . generic === 'object' ) {
3939 yield `<` ;
@@ -61,7 +61,7 @@ export function* generateScriptSetup(
6161 }
6262 if ( scriptSetupRanges . defineProps ?. arg ) {
6363 yield `const __VLS_propsOption = ` ;
64- yield generateSfcBlockSection (
64+ yield * generateSfcBlockSection (
6565 scriptSetup ,
6666 scriptSetupRanges . defineProps . arg . start ,
6767 scriptSetupRanges . defineProps . arg . end ,
@@ -116,7 +116,7 @@ export function* generateScriptSetup(
116116 yield * generateSetupFunction ( options , ctx , scriptSetup , scriptSetupRanges , 'export default' ) ;
117117 }
118118 else {
119- yield * generateConstExport ( options , scriptSetup ) ;
119+ yield * generateConstExport ( scriptSetup ) ;
120120 yield `await (async () => {${ newLine } ` ;
121121 yield * generateSetupFunction ( options , ctx , scriptSetup , scriptSetupRanges , 'return' ) ;
122122 yield `})()${ endOfLine } ` ;
@@ -174,7 +174,7 @@ function* generateSetupFunction(
174174 transforms . push (
175175 insert ( callExp . start , function * ( ) {
176176 yield `let __VLS_exposed!: ` ;
177- yield generateSfcBlockSection ( scriptSetup , typeArg . start , typeArg . end , codeFeatures . all ) ;
177+ yield * generateSfcBlockSection ( scriptSetup , typeArg . start , typeArg . end , codeFeatures . all ) ;
178178 yield endOfLine ;
179179 } ) ,
180180 replace ( typeArg . start , typeArg . end , function * ( ) {
@@ -186,7 +186,7 @@ function* generateSetupFunction(
186186 transforms . push (
187187 insert ( callExp . start , function * ( ) {
188188 yield `const __VLS_exposed = ` ;
189- yield generateSfcBlockSection ( scriptSetup , arg . start , arg . end , codeFeatures . all ) ;
189+ yield * generateSfcBlockSection ( scriptSetup , arg . start , arg . end , codeFeatures . all ) ;
190190 yield endOfLine ;
191191 } ) ,
192192 replace ( arg . start , arg . end , function * ( ) {
@@ -224,7 +224,7 @@ function* generateSetupFunction(
224224 transforms . push (
225225 insert ( callExp . end , function * ( ) {
226226 yield ` as Omit<__VLS_StyleModules, '$style'>[` ;
227- yield generateSfcBlockSection ( scriptSetup , arg . start , arg . end , codeFeatures . withoutSemantic ) ;
227+ yield * generateSfcBlockSection ( scriptSetup , arg . start , arg . end , codeFeatures . withoutSemantic ) ;
228228 yield `])` ;
229229 } ) ,
230230 replace ( arg . start , arg . end , function * ( ) {
@@ -264,7 +264,7 @@ function* generateSetupFunction(
264264 yield `<` ;
265265 if ( arg ) {
266266 yield `__VLS_TemplateRefs[` ;
267- yield generateSfcBlockSection ( scriptSetup , arg . start , arg . end , codeFeatures . withoutSemantic ) ;
267+ yield * generateSfcBlockSection ( scriptSetup , arg . start , arg . end , codeFeatures . withoutSemantic ) ;
268268 yield `]` ;
269269 }
270270 else {
@@ -283,7 +283,7 @@ function* generateSetupFunction(
283283 yield ` as __VLS_UseTemplateRef<` ;
284284 if ( arg ) {
285285 yield `__VLS_TemplateRefs[` ;
286- yield generateSfcBlockSection ( scriptSetup , arg . start , arg . end , codeFeatures . withoutSemantic ) ;
286+ yield * generateSfcBlockSection ( scriptSetup , arg . start , arg . end , codeFeatures . withoutSemantic ) ;
287287 yield `]` ;
288288 }
289289 else {
@@ -306,10 +306,9 @@ function* generateSetupFunction(
306306 Math . max ( scriptSetupRanges . importSectionEndOffset , scriptSetupRanges . leadingCommentEndOffset ) ,
307307 scriptSetup . content . length ,
308308 transforms ,
309- ( start , end ) => generateSfcBlockSection ( scriptSetup , start , end , codeFeatures . all ) ,
309+ ( start , end ) =>
310+ generateSfcBlockSection ( scriptSetup , start , end , codeFeatures . all , end === scriptSetup . content . length ) ,
310311 ) ;
311- // #3632
312- yield * generatePartiallyEnding ( scriptSetup . name , scriptSetup . content . length ) ;
313312 yield * generateMacros ( options , ctx ) ;
314313
315314 const hasSlots = ! ! (
@@ -325,7 +324,7 @@ function* generateSetupFunction(
325324 if ( syntax ) {
326325 const prefix = syntax === 'return'
327326 ? [ `return ` ]
328- : generateConstExport ( options , scriptSetup ) ;
327+ : generateConstExport ( scriptSetup ) ;
329328 if ( hasSlots ) {
330329 yield `const __VLS_base = ` ;
331330 yield * generateComponent ( options , ctx , scriptSetup , scriptSetupRanges ) ;
@@ -369,7 +368,7 @@ function* generateDefineWithTypeTransforms(
369368 if ( typeArg ) {
370369 yield insert ( statement . start , function * ( ) {
371370 yield `type ${ typeName } = ` ;
372- yield generateSfcBlockSection ( scriptSetup , typeArg . start , typeArg . end , codeFeatures . all ) ;
371+ yield * generateSfcBlockSection ( scriptSetup , typeArg . start , typeArg . end , codeFeatures . all ) ;
373372 yield endOfLine ;
374373 } ) ;
375374 yield replace ( typeArg . start , typeArg . end , function * ( ) {
@@ -385,21 +384,21 @@ function* generateDefineWithTypeTransforms(
385384 else if ( typeArg ) {
386385 yield replace ( statement . start , typeArg . start , function * ( ) {
387386 yield `const ${ defaultName } = ` ;
388- yield generateSfcBlockSection ( scriptSetup , callExp . start , typeArg . start , codeFeatures . all ) ;
387+ yield * generateSfcBlockSection ( scriptSetup , callExp . start , typeArg . start , codeFeatures . all ) ;
389388 } ) ;
390389 yield replace ( typeArg . end , callExp . end , function * ( ) {
391- yield generateSfcBlockSection ( scriptSetup , typeArg . end , callExp . end , codeFeatures . all ) ;
390+ yield * generateSfcBlockSection ( scriptSetup , typeArg . end , callExp . end , codeFeatures . all ) ;
392391 yield endOfLine ;
393- yield generateSfcBlockSection ( scriptSetup , statement . start , callExp . start , codeFeatures . all ) ;
392+ yield * generateSfcBlockSection ( scriptSetup , statement . start , callExp . start , codeFeatures . all ) ;
394393 yield defaultName ;
395394 } ) ;
396395 }
397396 else {
398397 yield replace ( statement . start , callExp . end , function * ( ) {
399398 yield `const ${ defaultName } = ` ;
400- yield generateSfcBlockSection ( scriptSetup , callExp . start , callExp . end , codeFeatures . all ) ;
399+ yield * generateSfcBlockSection ( scriptSetup , callExp . start , callExp . end , codeFeatures . all ) ;
401400 yield endOfLine ;
402- yield generateSfcBlockSection ( scriptSetup , statement . start , callExp . start , codeFeatures . all ) ;
401+ yield * generateSfcBlockSection ( scriptSetup , statement . start , callExp . start , codeFeatures . all ) ;
403402 yield defaultName ;
404403 } ) ;
405404 }
@@ -410,7 +409,7 @@ function* generateDefineWithTypeTransforms(
410409 } ) ;
411410 yield insert ( statement . end , function * ( ) {
412411 yield endOfLine ;
413- yield generateSfcBlockSection ( scriptSetup , statement . start , callExp . start , codeFeatures . all ) ;
412+ yield * generateSfcBlockSection ( scriptSetup , statement . start , callExp . start , codeFeatures . all ) ;
414413 yield defaultName ;
415414 } ) ;
416415 }
@@ -425,7 +424,7 @@ function* generatePublicProps(
425424) : Generator < Code > {
426425 if ( scriptSetupRanges . defineProps ?. typeArg && scriptSetupRanges . withDefaults ?. arg ) {
427426 yield `const __VLS_defaults = ` ;
428- yield generateSfcBlockSection (
427+ yield * generateSfcBlockSection (
429428 scriptSetup ,
430429 scriptSetupRanges . withDefaults . arg . start ,
431430 scriptSetupRanges . withDefaults . arg . end ,
0 commit comments