@vue/language-core
Advanced tools
Comparing version 2.0.17 to 2.0.18
@@ -10,8 +10,8 @@ "use strict"; | ||
// @ts-ignore | ||
type __VLS_IntrinsicElements = __VLS_PickNotAny<import('vue/jsx-runtime').JSX.IntrinsicElements, __VLS_PickNotAny<globalThis.JSX.IntrinsicElements, Record<string, any>>>; | ||
type __VLS_IntrinsicElements = __VLS_PickNotAny<import('${vueCompilerOptions.lib}/jsx-runtime').JSX.IntrinsicElements, __VLS_PickNotAny<globalThis.JSX.IntrinsicElements, Record<string, any>>>; | ||
// @ts-ignore | ||
type __VLS_Element = __VLS_PickNotAny<import('vue/jsx-runtime').JSX.Element, globalThis.JSX.Element>; | ||
type __VLS_Element = __VLS_PickNotAny<import('${vueCompilerOptions.lib}/jsx-runtime').JSX.Element, globalThis.JSX.Element>; | ||
// @ts-ignore | ||
type __VLS_GlobalComponents = ${[ | ||
`__VLS_PickNotAny<import('vue').GlobalComponents, {}>`, | ||
`__VLS_PickNotAny<import('${vueCompilerOptions.lib}').GlobalComponents, {}>`, | ||
`__VLS_PickNotAny<import('@vue/runtime-core').GlobalComponents, {}>`, | ||
@@ -21,2 +21,6 @@ `__VLS_PickNotAny<import('@vue/runtime-dom').GlobalComponents, {}>`, | ||
].join(' & ')}; | ||
type __VLS_BuiltInPublicProps = | ||
__VLS_PickNotAny<import('${vueCompilerOptions.lib}').VNodeProps, {}> | ||
& __VLS_PickNotAny<import('${vueCompilerOptions.lib}').AllowedComponentProps, {}> | ||
& __VLS_PickNotAny<import('${vueCompilerOptions.lib}').ComponentCustomProps, {}>; | ||
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false; | ||
@@ -72,4 +76,2 @@ type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A; | ||
type __VLS_FillingEventArg_ParametersLength<E extends (...args: any) => any> = __VLS_IsAny<Parameters<E>> extends true ? -1 : Parameters<E>['length']; | ||
type __VLS_FillingEventArg<E> = E extends (...args: any) => any ? __VLS_FillingEventArg_ParametersLength<E> extends 0 ? ($event?: undefined) => ReturnType<E> : E : E; | ||
function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K): | ||
@@ -87,8 +89,2 @@ T extends new (...args: any) => any | ||
function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): Parameters<T>['length'] extends 2 ? [any] : []; | ||
function __VLS_pickEvent<E1, E2>(emitEvent: E1, propEvent: E2): __VLS_FillingEventArg< | ||
__VLS_PickNotAny< | ||
__VLS_AsFunctionOrAny<E2>, | ||
__VLS_AsFunctionOrAny<E1> | ||
> | ||
> | undefined; | ||
function __VLS_pickFunctionalComponentCtx<T, K>(comp: T, compInstance: K): __VLS_PickNotAny< | ||
@@ -95,0 +91,0 @@ '__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: infer Ctx } ? Ctx : never : any |
@@ -258,6 +258,2 @@ "use strict"; | ||
yield common_1.endOfLine; | ||
yield `type __VLS_BuiltInPublicProps =${common_1.newLine}` | ||
+ ` import('${options.vueCompilerOptions.lib}').VNodeProps${common_1.newLine}` | ||
+ ` & import('${options.vueCompilerOptions.lib}').AllowedComponentProps${common_1.newLine}` | ||
+ ` & import('${options.vueCompilerOptions.lib}').ComponentCustomProps${common_1.endOfLine}`; | ||
if (scriptSetupRanges.defineProp.length) { | ||
@@ -264,0 +260,0 @@ yield `const __VLS_defaults = {${common_1.newLine}`; |
@@ -35,3 +35,2 @@ "use strict"; | ||
let dynamicTagInfo; | ||
let usedComponentEventsVar = false; | ||
if (isComponentTag) { | ||
@@ -167,3 +166,3 @@ for (const prop of node.props) { | ||
ctx.usedComponentCtxVars.add(componentCtxVar); | ||
yield* (0, elementEvents_1.generateElementEvents)(options, ctx, node, var_functionalComponent, var_componentInstance, var_componentEmit, var_componentEvents, () => usedComponentEventsVar = true); | ||
const usedComponentEventsVar = yield* (0, elementEvents_1.generateElementEvents)(options, ctx, node, var_functionalComponent, var_componentInstance, var_componentEmit, var_componentEvents); | ||
const slotDir = node.props.find(p => p.type === CompilerDOM.NodeTypes.DIRECTIVE && p.name === 'slot'); | ||
@@ -170,0 +169,0 @@ if (slotDir) { |
@@ -6,5 +6,5 @@ import * as CompilerDOM from '@vue/compiler-dom'; | ||
import type { TemplateCodegenOptions } from './index'; | ||
export declare function generateElementEvents(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, componentVar: string, componentInstanceVar: string, emitVar: string, eventsVar: string, used: () => void): Generator<Code>; | ||
export declare function generateEventArg(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, arg: CompilerDOM.SimpleExpressionNode, access: boolean, enableHover: boolean): Generator<Code>; | ||
export declare function generateElementEvents(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, componentVar: string, componentInstanceVar: string, emitVar: string, eventsVar: string): Generator<Code>; | ||
export declare function generateEventArg(ctx: TemplateCodegenContext, arg: CompilerDOM.SimpleExpressionNode, enableHover: boolean): Generator<Code>; | ||
export declare function generateEventExpression(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode): Generator<Code>; | ||
export declare function isCompoundExpression(ts: typeof import('typescript'), ast: ts.SourceFile): boolean; |
@@ -10,29 +10,44 @@ "use strict"; | ||
const interpolation_1 = require("./interpolation"); | ||
const objectProperty_1 = require("./objectProperty"); | ||
function* generateElementEvents(options, ctx, node, componentVar, componentInstanceVar, emitVar, eventsVar, used) { | ||
function* generateElementEvents(options, ctx, node, componentVar, componentInstanceVar, emitVar, eventsVar) { | ||
let usedComponentEventsVar = false; | ||
let propsVar; | ||
for (const prop of node.props) { | ||
if (prop.type === CompilerDOM.NodeTypes.DIRECTIVE | ||
&& prop.name === 'on' | ||
&& prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) { | ||
used(); | ||
const eventVar = ctx.getInternalVariable(); | ||
yield `let ${eventVar} = {${common_1.newLine}`; | ||
&& prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION | ||
&& !prop.arg.loc.source.startsWith('[') | ||
&& !prop.arg.loc.source.endsWith(']')) { | ||
usedComponentEventsVar = true; | ||
if (!propsVar) { | ||
propsVar = ctx.getInternalVariable(); | ||
yield `let ${propsVar}!: __VLS_FunctionalComponentProps<typeof ${componentVar}, typeof ${componentInstanceVar}>${common_1.endOfLine}`; | ||
} | ||
const originalPropName = (0, shared_1.camelize)('on-' + prop.arg.loc.source); | ||
const originalPropNameObjectKey = common_1.variableNameRegex.test(originalPropName) | ||
? originalPropName | ||
: `'${originalPropName}'`; | ||
yield `const ${ctx.getInternalVariable()}: `; | ||
if (!options.vueCompilerOptions.strictTemplates) { | ||
yield `Record<string, unknown> & `; | ||
} | ||
yield `(`; | ||
yield `__VLS_IsAny<__VLS_AsFunctionOrAny<typeof ${propsVar}['${originalPropName}']>> extends false${common_1.newLine}`; | ||
yield `? typeof ${propsVar}${common_1.newLine}`; | ||
yield `: __VLS_IsAny<typeof ${eventsVar}['${prop.arg.loc.source}']> extends false${common_1.newLine}`; | ||
yield `? {${common_1.newLine}`; | ||
yield `/**__VLS_emit,${emitVar},${prop.arg.loc.source}*/${common_1.newLine}`; | ||
yield `'${prop.arg.loc.source}': __VLS_pickEvent(`; | ||
yield `${eventsVar}['${prop.arg.loc.source}'], `; | ||
yield `({} as __VLS_FunctionalComponentProps<typeof ${componentVar}, typeof ${componentInstanceVar}>)`; | ||
yield* generateEventArg(options, ctx, prop.arg, true, false); | ||
yield `) }${common_1.endOfLine}`; | ||
yield `${eventVar} = { `; | ||
if (prop.arg.loc.source.startsWith('[') && prop.arg.loc.source.endsWith(']')) { | ||
yield `[(`; | ||
yield* (0, interpolation_1.generateInterpolation)(options, ctx, prop.arg.loc.source.slice(1, -1), prop.arg.loc, prop.arg.loc.start.offset + 1, ctx.codeFeatures.all, '', ''); | ||
yield `)!]`; | ||
yield `${originalPropNameObjectKey}?: typeof ${eventsVar}['${prop.arg.loc.source}']${common_1.newLine}`; | ||
yield `}${common_1.newLine}`; | ||
if (prop.arg.loc.source !== (0, shared_1.camelize)(prop.arg.loc.source)) { | ||
yield `: __VLS_IsAny<typeof ${eventsVar}['${(0, shared_1.camelize)(prop.arg.loc.source)}']> extends false${common_1.newLine}`; | ||
yield `? {${common_1.newLine}`; | ||
yield `/**__VLS_emit,${emitVar},${(0, shared_1.camelize)(prop.arg.loc.source)}*/${common_1.newLine}`; | ||
yield `${originalPropNameObjectKey}?: typeof ${eventsVar}['${(0, shared_1.camelize)(prop.arg.loc.source)}']${common_1.newLine}`; | ||
yield `}${common_1.newLine}`; | ||
} | ||
else { | ||
yield* (0, objectProperty_1.generateObjectProperty)(options, ctx, prop.arg.loc.source, prop.arg.loc.start.offset, ctx.codeFeatures.withoutHighlightAndCompletionAndNavigation, prop.arg.loc); | ||
} | ||
yield `: typeof ${propsVar}${common_1.newLine}`; | ||
yield `) = {${common_1.newLine}`; | ||
yield* generateEventArg(ctx, prop.arg, true); | ||
yield `: `; | ||
yield* generateEventExpression(options, ctx, prop); | ||
yield common_1.newLine; | ||
yield `}${common_1.endOfLine}`; | ||
@@ -49,2 +64,3 @@ } | ||
} | ||
return usedComponentEventsVar; | ||
} | ||
@@ -68,3 +84,3 @@ exports.generateElementEvents = generateElementEvents; | ||
}; | ||
function* generateEventArg(options, ctx, arg, access, enableHover) { | ||
function* generateEventArg(ctx, arg, enableHover) { | ||
const features = enableHover | ||
@@ -76,11 +92,3 @@ ? { | ||
: eventArgFeatures; | ||
if (arg.loc.source.startsWith('[') && arg.loc.source.endsWith(']')) { | ||
yield `[`; | ||
yield* (0, interpolation_1.generateInterpolation)(options, ctx, arg.loc.source.slice(1, -1), arg.loc, arg.loc.start.offset + 1, ctx.codeFeatures.all, '', ''); | ||
yield `]`; | ||
} | ||
else if (common_1.variableNameRegex.test((0, shared_1.camelize)(arg.loc.source))) { | ||
if (access) { | ||
yield `.`; | ||
} | ||
if (common_1.variableNameRegex.test((0, shared_1.camelize)(arg.loc.source))) { | ||
yield ['', 'template', arg.loc.start.offset, features]; | ||
@@ -91,9 +99,3 @@ yield `on`; | ||
else { | ||
if (access) { | ||
yield `[`; | ||
} | ||
yield* (0, common_1.wrapWith)(arg.loc.start.offset, arg.loc.end.offset, features, `'`, ['', 'template', arg.loc.start.offset, common_1.combineLastMapping], 'on', ...(0, camelized_1.generateCamelized)((0, shared_1.capitalize)(arg.loc.source), arg.loc.start.offset, common_1.combineLastMapping), `'`); | ||
if (access) { | ||
yield `]`; | ||
} | ||
} | ||
@@ -100,0 +102,0 @@ } |
@@ -15,49 +15,32 @@ "use strict"; | ||
function* generateElementProps(options, ctx, node, props, enableCodeFeatures, propsFailedExps) { | ||
let styleAttrNum = 0; | ||
let classAttrNum = 0; | ||
const isIntrinsicElement = node.tagType === CompilerDOM.ElementTypes.ELEMENT || node.tagType === CompilerDOM.ElementTypes.TEMPLATE; | ||
const canCamelize = node.tagType === CompilerDOM.ElementTypes.COMPONENT; | ||
if (props.some(prop => prop.type === CompilerDOM.NodeTypes.DIRECTIVE | ||
&& prop.name === 'bind' | ||
&& !prop.arg | ||
&& prop.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION)) { | ||
// fix https://github.com/vuejs/language-tools/issues/2166 | ||
styleAttrNum++; | ||
classAttrNum++; | ||
} | ||
if (isIntrinsicElement) { | ||
for (const prop of props) { | ||
if (prop.type === CompilerDOM.NodeTypes.DIRECTIVE | ||
&& prop.name === 'on') { | ||
if (prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) { | ||
yield* (0, elementEvents_1.generateEventArg)(options, ctx, prop.arg, false, true); | ||
for (const prop of props) { | ||
if (prop.type === CompilerDOM.NodeTypes.DIRECTIVE | ||
&& prop.name === 'on') { | ||
if (prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION | ||
&& !prop.arg.loc.source.startsWith('[') | ||
&& !prop.arg.loc.source.endsWith(']')) { | ||
if (isIntrinsicElement) { | ||
yield `...{ `; | ||
yield* (0, elementEvents_1.generateEventArg)(ctx, prop.arg, true); | ||
yield `: `; | ||
yield* (0, elementEvents_1.generateEventExpression)(options, ctx, prop); | ||
yield `,${common_1.newLine}`; | ||
yield `}, `; | ||
} | ||
else if (prop.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) { | ||
propsFailedExps?.push(prop.exp); | ||
else { | ||
yield `...{ '${(0, shared_1.camelize)('on-' + prop.arg.loc.source)}': {} as any }, `; | ||
} | ||
} | ||
} | ||
} | ||
else { | ||
let generatedEvent = false; | ||
for (const prop of props) { | ||
if (prop.type === CompilerDOM.NodeTypes.DIRECTIVE | ||
&& prop.name === 'on' | ||
&& prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) { | ||
if (prop.arg.loc.source.startsWith('[') && prop.arg.loc.source.endsWith(']')) { | ||
continue; | ||
else { | ||
if (prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION | ||
&& prop.arg.loc.source.startsWith('[') | ||
&& prop.arg.loc.source.endsWith(']')) { | ||
propsFailedExps?.push(prop.arg); | ||
} | ||
if (!generatedEvent) { | ||
yield `...{ `; | ||
generatedEvent = true; | ||
if (prop.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) { | ||
propsFailedExps?.push(prop.exp); | ||
} | ||
yield `'${(0, shared_1.camelize)('on-' + prop.arg.loc.source)}': {} as any, `; | ||
} | ||
} | ||
if (generatedEvent) { | ||
yield `}, `; | ||
} | ||
} | ||
@@ -69,16 +52,13 @@ for (const prop of props) { | ||
&& (!prop.exp || prop.exp.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION)) { | ||
let propName = prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION | ||
? prop.arg.constType === CompilerDOM.ConstantTypes.CAN_STRINGIFY | ||
let propName; | ||
if (prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) { | ||
propName = prop.arg.constType === CompilerDOM.ConstantTypes.CAN_STRINGIFY | ||
? prop.arg.content | ||
: prop.arg.loc.source | ||
: getModelValuePropName(node, options.vueCompilerOptions.target, options.vueCompilerOptions); | ||
if (prop.modifiers.some(m => m === 'prop' || m === 'attr')) { | ||
propName = propName?.substring(1); | ||
: prop.arg.loc.source; | ||
} | ||
else { | ||
propName = getModelValuePropName(node, options.vueCompilerOptions.target, options.vueCompilerOptions); | ||
} | ||
if (propName === undefined | ||
|| options.vueCompilerOptions.dataAttributes.some(pattern => (0, minimatch_1.minimatch)(propName, pattern)) | ||
|| (propName === 'style' && ++styleAttrNum >= 2) | ||
|| (propName === 'class' && ++classAttrNum >= 2) | ||
|| (propName === 'name' && node.tagType === CompilerDOM.ElementTypes.SLOT) // #2308 | ||
) { | ||
|| options.vueCompilerOptions.dataAttributes.some(pattern => (0, minimatch_1.minimatch)(propName, pattern))) { | ||
if (prop.exp && prop.exp.constType !== CompilerDOM.ConstantTypes.CAN_STRINGIFY) { | ||
@@ -89,2 +69,6 @@ propsFailedExps?.push(prop.exp); | ||
} | ||
if (prop.modifiers.some(m => m === 'prop' || m === 'attr')) { | ||
propName = propName.substring(1); | ||
} | ||
const shouldSpread = propName === 'style' || propName === 'class'; | ||
const shouldCamelize = canCamelize | ||
@@ -94,6 +78,7 @@ && (!prop.arg || (prop.arg.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && prop.arg.isStatic)) // isStatic | ||
&& !options.vueCompilerOptions.htmlAttributes.some(pattern => (0, minimatch_1.minimatch)(propName, pattern)); | ||
const codes = (0, common_1.wrapWith)(prop.loc.start.offset, prop.loc.end.offset, ctx.codeFeatures.verification, ...(0, objectProperty_1.generateObjectProperty)(options, ctx, propName, prop.arg | ||
? prop.arg.loc.start.offset | ||
: prop.loc.start.offset, prop.arg | ||
? { | ||
if (shouldSpread) { | ||
yield `...{ `; | ||
} | ||
const codes = (0, common_1.wrapWith)(prop.loc.start.offset, prop.loc.end.offset, ctx.codeFeatures.verification, ...(prop.arg | ||
? (0, objectProperty_1.generateObjectProperty)(options, ctx, propName, prop.arg.loc.start.offset, { | ||
...ctx.codeFeatures.withoutHighlightAndCompletion, | ||
@@ -106,4 +91,4 @@ navigation: ctx.codeFeatures.withoutHighlightAndCompletion.navigation | ||
: false, | ||
} | ||
: ctx.codeFeatures.withoutHighlightAndCompletion, prop.loc.name_2 ?? (prop.loc.name_2 = {}), shouldCamelize), `: (`, ...genereatePropExp(options, ctx, prop.exp, ctx.codeFeatures.all, prop.arg?.loc.start.offset === prop.exp?.loc.start.offset, enableCodeFeatures), `)`); | ||
}, prop.loc.name_2 ?? (prop.loc.name_2 = {}), shouldCamelize) | ||
: [propName]), `: (`, ...genereatePropExp(options, ctx, prop.exp, ctx.codeFeatures.all, prop.arg?.loc.start.offset === prop.exp?.loc.start.offset, enableCodeFeatures), `)`); | ||
if (!enableCodeFeatures) { | ||
@@ -115,2 +100,5 @@ yield (0, language_core_1.toString)([...codes]); | ||
} | ||
if (shouldSpread) { | ||
yield ` }`; | ||
} | ||
yield `, `; | ||
@@ -120,17 +108,15 @@ } | ||
if (options.vueCompilerOptions.dataAttributes.some(pattern => (0, minimatch_1.minimatch)(prop.name, pattern)) | ||
|| (prop.name === 'style' && ++styleAttrNum >= 2) | ||
|| (prop.name === 'class' && ++classAttrNum >= 2) | ||
|| (prop.name === 'name' && node.tagType === CompilerDOM.ElementTypes.SLOT) // #2308 | ||
) { | ||
continue; | ||
} | ||
if (options.vueCompilerOptions.target < 3 | ||
&& prop.name === 'persisted' | ||
&& node.tag.toLowerCase() === 'transition') { | ||
// Vue 2 Transition doesn't support "persisted" property but `@vue/compiler-dom always adds it (#3881) | ||
|| (options.vueCompilerOptions.target < 3 | ||
&& prop.name === 'persisted' | ||
&& node.tag.toLowerCase() === 'transition')) { | ||
continue; | ||
} | ||
const shouldSpread = prop.name === 'style' || prop.name === 'class'; | ||
const shouldCamelize = canCamelize | ||
&& (0, shared_2.hyphenateAttr)(prop.name) === prop.name | ||
&& !options.vueCompilerOptions.htmlAttributes.some(pattern => (0, minimatch_1.minimatch)(prop.name, pattern)); | ||
if (shouldSpread) { | ||
yield `...{ `; | ||
} | ||
const codes = (0, common_1.conditionWrapWith)(enableCodeFeatures, prop.loc.start.offset, prop.loc.end.offset, ctx.codeFeatures.verification, ...(0, objectProperty_1.generateObjectProperty)(options, ctx, prop.name, prop.loc.start.offset, shouldCamelize | ||
@@ -155,2 +141,5 @@ ? { | ||
} | ||
if (shouldSpread) { | ||
yield ` }`; | ||
} | ||
yield `, `; | ||
@@ -157,0 +146,0 @@ } |
@@ -34,8 +34,18 @@ "use strict"; | ||
yield `) {${common_1.newLine}`; | ||
for (const varName of forBlockVars) { | ||
ctx.addLocalVariable(varName); | ||
} | ||
for (const argument of node.codegenNode?.children.arguments ?? []) { | ||
if (argument.type === CompilerDOM.NodeTypes.JS_FUNCTION_EXPRESSION | ||
&& argument.returns.type === CompilerDOM.NodeTypes.VNODE_CALL | ||
&& argument.returns.props?.type === CompilerDOM.NodeTypes.JS_OBJECT_EXPRESSION) { | ||
for (const prop of argument.returns.props.properties) { | ||
yield* (0, interpolation_1.generateInterpolation)(options, ctx, prop.value.loc.source, prop.value.loc, prop.value.loc.start.offset, ctx.codeFeatures.all, '(', ')'); | ||
yield common_1.endOfLine; | ||
} | ||
} | ||
} | ||
if ((0, index_1.isFragment)(node)) { | ||
yield* ctx.resetDirectiveComments('end of v-for start'); | ||
} | ||
for (const varName of forBlockVars) { | ||
ctx.addLocalVariable(varName); | ||
} | ||
let prev; | ||
@@ -42,0 +52,0 @@ for (const childNode of node.children) { |
@@ -15,2 +15,3 @@ import { type VueLanguagePlugin } from './types'; | ||
resolveTemplateCompilerOptions?(options: import("@vue/compiler-dom").CompilerOptions): import("@vue/compiler-dom").CompilerOptions; | ||
compileSFCScript?(lang: string, script: string): import("typescript").SourceFile | undefined; | ||
compileSFCTemplate?(lang: string, template: string, options: import("@vue/compiler-dom").CompilerOptions): import("@vue/compiler-dom").CodegenResult | undefined; | ||
@@ -17,0 +18,0 @@ updateSFCTemplate?(oldResult: import("@vue/compiler-dom").CodegenResult, textChange: { |
@@ -22,2 +22,3 @@ "use strict"; | ||
const vue_sfc_template_1 = require("./plugins/vue-sfc-template"); | ||
const vue_script_js_1 = require("./plugins/vue-script-js"); | ||
const vue_template_html_1 = require("./plugins/vue-template-html"); | ||
@@ -31,2 +32,3 @@ const vue_template_inline_css_1 = require("./plugins/vue-template-inline-css"); | ||
const plugins = [ | ||
vue_script_js_1.default, | ||
vue_template_html_1.default, | ||
@@ -33,0 +35,0 @@ vue_template_inline_css_1.default, |
@@ -45,2 +45,3 @@ "use strict"; | ||
if (sfc.descriptor.template) { | ||
sfc.descriptor.template.lang = 'md'; | ||
transformRange(sfc.descriptor.template); | ||
@@ -47,0 +48,0 @@ } |
@@ -7,3 +7,3 @@ "use strict"; | ||
compileSFCTemplate(lang, template, options) { | ||
if (lang === 'html') { | ||
if (lang === 'html' || lang === 'md') { | ||
const compiler = modules['@vue/compiler-dom']; | ||
@@ -10,0 +10,0 @@ return compiler.compile(template, { |
@@ -71,2 +71,3 @@ import type * as CompilerDOM from '@vue/compiler-dom'; | ||
resolveTemplateCompilerOptions?(options: CompilerDOM.CompilerOptions): CompilerDOM.CompilerOptions; | ||
compileSFCScript?(lang: string, script: string): ts.SourceFile | undefined; | ||
compileSFCTemplate?(lang: string, template: string, options: CompilerDOM.CompilerOptions): CompilerDOM.CodegenResult | undefined; | ||
@@ -73,0 +74,0 @@ updateSFCTemplate?(oldResult: CompilerDOM.CodegenResult, textChange: { |
@@ -28,3 +28,12 @@ "use strict"; | ||
}); | ||
const ast = (0, computeds_1.computed)(() => ts.createSourceFile(fileName + '.' + base.lang, base.content, 99)); | ||
const ast = (0, computeds_1.computed)(() => { | ||
for (const plugin of plugins) { | ||
const ast = plugin.compileSFCScript?.(base.lang, base.content); | ||
if (ast) { | ||
return ast; | ||
; | ||
} | ||
} | ||
return ts.createSourceFile(fileName + '.' + base.lang, '', 99); | ||
}); | ||
return mergeObject(base, { | ||
@@ -45,3 +54,12 @@ get src() { return src(); }, | ||
}); | ||
const ast = (0, computeds_1.computed)(() => ts.createSourceFile(fileName + '.' + base.lang, base.content, 99)); | ||
const ast = (0, computeds_1.computed)(() => { | ||
for (const plugin of plugins) { | ||
const ast = plugin.compileSFCScript?.(base.lang, base.content); | ||
if (ast) { | ||
return ast; | ||
; | ||
} | ||
} | ||
return ts.createSourceFile(fileName + '.' + base.lang, '', 99); | ||
}); | ||
return mergeObject(base, { | ||
@@ -48,0 +66,0 @@ get generic() { return generic(); }, |
{ | ||
"name": "@vue/language-core", | ||
"version": "2.0.17", | ||
"version": "2.0.18", | ||
"license": "MIT", | ||
@@ -15,3 +15,3 @@ "files": [ | ||
"dependencies": { | ||
"@volar/language-core": "~2.2.2", | ||
"@volar/language-core": "~2.2.4", | ||
"@vue/compiler-dom": "^3.4.0", | ||
@@ -38,3 +38,3 @@ "@vue/shared": "^3.4.0", | ||
}, | ||
"gitHead": "968039cbb07961f318b4bf122bfa8e3e4a824277" | ||
"gitHead": "7aac2805f03b17e4c624335f509d502002bb75a8" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
293845
114
6528
Updated@volar/language-core@~2.2.4