Skip to content

Commit

Permalink
chore(language-core): virtual code adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Apr 26, 2024
1 parent 572ee13 commit 0b4aabc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 1 addition & 2 deletions packages/language-core/lib/codegen/script/component.ts
Expand Up @@ -75,8 +75,7 @@ export function* generateScriptSetupOptions(
yield `${ctx.helperTypes.WithDefaults.name}<`;
}
yield `${ctx.helperTypes.TypePropsToOption.name}<`;
yield `typeof __VLS_componentProps`;
yield `>`;
yield `typeof __VLS_componentProps>`;
if (scriptSetupRanges.props.withDefaults?.arg) {
yield `, typeof __VLS_withDefaultsArg>`;
}
Expand Down
8 changes: 5 additions & 3 deletions packages/language-core/lib/codegen/script/template.ts
Expand Up @@ -128,10 +128,7 @@ function* generateTemplateContext(
}
yield endOfLine;
yield `let __VLS_styleScopedClasses!: __VLS_StyleScopedClasses | keyof __VLS_StyleScopedClasses | (keyof __VLS_StyleScopedClasses)[]${endOfLine}`;

yield `/* CSS variable injection */${newLine}`;
yield* generateCssVars(options, templateCodegenCtx);
yield `/* CSS variable injection end */${newLine}`;

if (options.templateCodegen) {
for (const code of options.templateCodegen.tsCodes) {
Expand Down Expand Up @@ -190,6 +187,10 @@ function* generateCssClassProperty(
}

function* generateCssVars(options: ScriptCodegenOptions, ctx: TemplateCodegenContext): Generator<Code> {
if (!options.sfc.styles.length) {
return;
}
yield `// CSS variable injection ${newLine}`;
for (const style of options.sfc.styles) {
for (const cssBind of style.cssVars) {
for (const [segment, offset, onlyError] of forEachInterpolationSegment(
Expand Down Expand Up @@ -217,6 +218,7 @@ function* generateCssVars(options: ScriptCodegenOptions, ctx: TemplateCodegenCon
yield endOfLine;
}
}
yield `// CSS variable injection end ${newLine}`;
}

export function getTemplateUsageVars(options: ScriptCodegenOptions, ctx: ScriptCodegenContext) {
Expand Down

0 comments on commit 0b4aabc

Please sign in to comment.