@vue/language-core
Advanced tools
Comparing version 2.0.26 to 2.0.28
export * from './lib/codegen/template'; | ||
export * from './lib/languageModule'; | ||
export * from './lib/languagePlugin'; | ||
export * from './lib/parsers/scriptSetupRanges'; | ||
@@ -4,0 +4,0 @@ export * from './lib/plugins'; |
@@ -19,3 +19,3 @@ "use strict"; | ||
__exportStar(require("./lib/codegen/template"), exports); | ||
__exportStar(require("./lib/languageModule"), exports); | ||
__exportStar(require("./lib/languagePlugin"), exports); | ||
__exportStar(require("./lib/parsers/scriptSetupRanges"), exports); | ||
@@ -22,0 +22,0 @@ __exportStar(require("./lib/plugins"), exports); |
@@ -63,3 +63,3 @@ "use strict"; | ||
} | ||
else { | ||
if (options.vueCompilerOptions.target < 3.5 || !ctx.generatedPropsType || scriptSetupRanges.props.withDefaults) { | ||
const codegens = []; | ||
@@ -66,0 +66,0 @@ if (ctx.generatedPropsType) { |
@@ -19,11 +19,4 @@ "use strict"; | ||
type __VLS_GlobalComponents = ${vueCompilerOptions.target >= 3.5 | ||
? `import('${vueCompilerOptions.lib}').GlobalComponents` | ||
? `import('${vueCompilerOptions.lib}').GlobalComponents;` | ||
: `import('${vueCompilerOptions.lib}').GlobalComponents & Pick<typeof import('${vueCompilerOptions.lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>;`} | ||
type __VLS_BuiltInPublicProps = ${vueCompilerOptions.target >= 3.4 | ||
? `import('${vueCompilerOptions.lib}').PublicProps;` | ||
: vueCompilerOptions.target >= 3.0 | ||
? `import('${vueCompilerOptions.lib}').VNodeProps | ||
& import('${vueCompilerOptions.lib}').AllowedComponentProps | ||
& import('${vueCompilerOptions.lib}').ComponentCustomProps;` | ||
: `globalThis.JSX.IntrinsicAttributes;`} | ||
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false; | ||
@@ -68,2 +61,3 @@ type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A; | ||
function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] }; | ||
function __VLS_nonNullable<T>(t: T): T extends null | undefined ? never : T; | ||
@@ -70,0 +64,0 @@ type __VLS_SelfComponent<N, C> = string extends N ? {} : N extends string ? { [P in N]: C } : {}; |
@@ -108,3 +108,13 @@ "use strict"; | ||
} | ||
yield common_1.endOfLine; | ||
yield `;`; | ||
if (options.sfc.scriptSetup) { | ||
// #4569 | ||
yield [ | ||
'', | ||
'scriptSetup', | ||
options.sfc.scriptSetup.content.length, | ||
exports.codeFeatures.verification, | ||
]; | ||
} | ||
yield common_1.newLine; | ||
if (options.globalTypes) { | ||
@@ -111,0 +121,0 @@ yield (0, globalTypes_1.generateGlobalTypes)(options.vueCompilerOptions); |
@@ -22,2 +22,11 @@ "use strict"; | ||
if (!options.scriptRanges?.exportDefault) { | ||
if (options.sfc.scriptSetup) { | ||
// #4569 | ||
yield [ | ||
'', | ||
'scriptSetup', | ||
options.sfc.scriptSetup.content.length, | ||
index_1.codeFeatures.verification, | ||
]; | ||
} | ||
yield `export default `; | ||
@@ -36,4 +45,4 @@ } | ||
yield `>(${common_1.newLine}` | ||
+ ` __VLS_props: Awaited<typeof __VLS_setup>['props'],${common_1.newLine}` | ||
+ ` __VLS_ctx?: ${ctx.helperTypes.Prettify.name}<Pick<Awaited<typeof __VLS_setup>, 'attrs' | 'emit' | 'slots'>>,${common_1.newLine}` // use __VLS_Prettify for less dts code | ||
+ ` __VLS_props: NonNullable<Awaited<typeof __VLS_setup>>['props'],${common_1.newLine}` | ||
+ ` __VLS_ctx?: ${ctx.helperTypes.Prettify.name}<Pick<NonNullable<Awaited<typeof __VLS_setup>>, 'attrs' | 'emit' | 'slots'>>,${common_1.newLine}` // use __VLS_Prettify for less dts code | ||
+ ` __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>['expose'],${common_1.newLine}` | ||
@@ -238,2 +247,10 @@ + ` __VLS_setup = (async () => {${common_1.newLine}`; | ||
yield `})${common_1.endOfLine}`; | ||
yield `type __VLS_BuiltInPublicProps = ${options.vueCompilerOptions.target >= 3.4 | ||
? `import('${options.vueCompilerOptions.lib}').PublicProps;` | ||
: options.vueCompilerOptions.target >= 3.0 | ||
? `import('${options.vueCompilerOptions.lib}').VNodeProps | ||
& import('${options.vueCompilerOptions.lib}').AllowedComponentProps | ||
& import('${options.vueCompilerOptions.lib}').ComponentCustomProps;` | ||
: `globalThis.JSX.IntrinsicAttributes;`}`; | ||
yield common_1.endOfLine; | ||
yield `let __VLS_functionalComponentProps!: `; | ||
@@ -278,2 +295,4 @@ yield `${ctx.helperTypes.OmitKeepDiscriminatedUnion.name}<InstanceType<typeof __VLS_fnComponent>['$props'], keyof __VLS_BuiltInPublicProps>`; | ||
yield (0, common_1.generateSfcBlockSection)(scriptSetup, defineProp.name.start, defineProp.name.end, index_1.codeFeatures.navigation); | ||
propName = scriptSetup.content.substring(defineProp.name.start, defineProp.name.end); | ||
propName = propName.replace(/['"]+/g, ''); | ||
} | ||
@@ -291,14 +310,3 @@ else if (defineProp.name) { | ||
: `?: `; | ||
if (defineProp.type) { | ||
yield scriptSetup.content.substring(defineProp.type.start, defineProp.type.end); | ||
} | ||
else if (!defineProp.nameIsString) { | ||
yield `NonNullable<typeof ${propName}['value']>`; | ||
} | ||
else if (defineProp.defaultValue) { | ||
yield `typeof __VLS_defaults['${propName}']`; | ||
} | ||
else { | ||
yield `any`; | ||
} | ||
yield* generateDefinePropType(scriptSetup, propName, defineProp); | ||
yield `,${common_1.newLine}`; | ||
@@ -347,8 +355,3 @@ if (defineProp.modifierType) { | ||
yield `'update:${propName}': [${propName}:`; | ||
if (defineProp.type) { | ||
yield scriptSetup.content.substring(defineProp.type.start, defineProp.type.end); | ||
} | ||
else { | ||
yield `any`; | ||
} | ||
yield* generateDefinePropType(scriptSetup, propName, defineProp); | ||
yield `]${common_1.endOfLine}`; | ||
@@ -366,2 +369,19 @@ } | ||
} | ||
function* generateDefinePropType(scriptSetup, propName, defineProp) { | ||
if (defineProp.type) { | ||
// Infer from defineProp<T> | ||
yield scriptSetup.content.substring(defineProp.type.start, defineProp.type.end); | ||
} | ||
else if ((defineProp.name && defineProp.nameIsString) || !defineProp.nameIsString) { | ||
// Infer from actual prop declaration code | ||
yield `NonNullable<typeof ${propName}['value']>`; | ||
} | ||
else if (defineProp.defaultValue) { | ||
// Infer from defineProp({default: T}) | ||
yield `typeof __VLS_defaults['${propName}']`; | ||
} | ||
else { | ||
yield `any`; | ||
} | ||
} | ||
//# sourceMappingURL=scriptSetup.js.map |
@@ -19,2 +19,3 @@ "use strict"; | ||
const templateChild_1 = require("./templateChild"); | ||
const objectProperty_1 = require("./objectProperty"); | ||
const colonReg = /:/g; | ||
@@ -172,2 +173,9 @@ function* generateComponent(options, ctx, node, currentComponent, componentCtxVar) { | ||
const usedComponentEventsVar = yield* (0, elementEvents_1.generateElementEvents)(options, ctx, node, var_functionalComponent, var_componentInstance, var_componentEmit, var_componentEvents); | ||
if (var_defineComponentCtx && ctx.usedComponentCtxVars.has(var_defineComponentCtx)) { | ||
yield `const ${componentCtxVar} = __VLS_nonNullable(__VLS_pickFunctionalComponentCtx(${var_originalComponent}, ${var_componentInstance}))${common_1.endOfLine}`; | ||
} | ||
if (usedComponentEventsVar) { | ||
yield `let ${var_componentEmit}!: typeof ${componentCtxVar}.emit${common_1.endOfLine}`; | ||
yield `let ${var_componentEvents}!: __VLS_NormalizeEmits<typeof ${var_componentEmit}>${common_1.endOfLine}`; | ||
} | ||
const slotDir = node.props.find(p => p.type === CompilerDOM.NodeTypes.DIRECTIVE && p.name === 'slot'); | ||
@@ -180,9 +188,2 @@ if (slotDir) { | ||
} | ||
if (var_defineComponentCtx && ctx.usedComponentCtxVars.has(var_defineComponentCtx)) { | ||
yield `const ${componentCtxVar} = __VLS_pickFunctionalComponentCtx(${var_originalComponent}, ${var_componentInstance})!${common_1.endOfLine}`; | ||
} | ||
if (usedComponentEventsVar) { | ||
yield `let ${var_componentEmit}!: typeof ${componentCtxVar}.emit${common_1.endOfLine}`; | ||
yield `let ${var_componentEvents}!: __VLS_NormalizeEmits<typeof ${var_componentEmit}>${common_1.endOfLine}`; | ||
} | ||
} | ||
@@ -277,7 +278,19 @@ function* generateElement(options, ctx, node, currentComponent, componentCtxVar) { | ||
const slotBlockVars = []; | ||
let hasProps = false; | ||
yield `const {`; | ||
if (slotDir?.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && slotDir.arg.content) { | ||
yield* (0, objectProperty_1.generateObjectProperty)(options, ctx, slotDir.arg.loc.source, slotDir.arg.loc.start.offset, slotDir.arg.isStatic ? ctx.codeFeatures.withoutHighlight : ctx.codeFeatures.all, slotDir.arg.loc); | ||
yield ': __VLS_thisSlot'; | ||
} | ||
else { | ||
yield `default: `; | ||
yield* (0, common_1.wrapWith)(slotDir.loc.start.offset, slotDir.loc.start.offset + (slotDir.loc.source.startsWith('#') | ||
? '#'.length | ||
: slotDir.loc.source.startsWith('v-slot:') | ||
? 'v-slot:'.length | ||
: 0), ctx.codeFeatures.withoutHighlightAndCompletion, `__VLS_thisSlot`); | ||
} | ||
yield `} = __VLS_nonNullable(${componentCtxVar}.slots)${common_1.endOfLine}`; | ||
if (slotDir?.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) { | ||
const slotAst = (0, common_1.createTsAst)(options.ts, slotDir, `(${slotDir.exp.content}) => {}`); | ||
(0, common_1.collectVars)(options.ts, slotAst, slotAst, slotBlockVars); | ||
hasProps = true; | ||
if (!slotDir.exp.content.includes(':')) { | ||
@@ -291,3 +304,3 @@ yield `const [`; | ||
]; | ||
yield `] = __VLS_getSlotParams(`; | ||
yield `] = __VLS_getSlotParams(__VLS_thisSlot)${common_1.endOfLine}`; | ||
} | ||
@@ -302,19 +315,5 @@ else { | ||
]; | ||
yield ` = __VLS_getSlotParam(`; | ||
yield ` = __VLS_getSlotParam(__VLS_thisSlot)${common_1.endOfLine}`; | ||
} | ||
} | ||
yield* (0, common_1.wrapWith)((slotDir.arg ?? slotDir).loc.start.offset, (slotDir.arg ?? slotDir).loc.end.offset, ctx.codeFeatures.verification, `(${componentCtxVar}.slots!)`, ...(slotDir?.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && slotDir.arg.content | ||
? (0, propertyAccess_1.generatePropertyAccess)(options, ctx, slotDir.arg.loc.source, slotDir.arg.loc.start.offset, slotDir.arg.isStatic ? ctx.codeFeatures.withoutHighlight : ctx.codeFeatures.all, slotDir.arg.loc) | ||
: [ | ||
`.`, | ||
...(0, common_1.wrapWith)(slotDir.loc.start.offset, slotDir.loc.start.offset + (slotDir.loc.source.startsWith('#') | ||
? '#'.length | ||
: slotDir.loc.source.startsWith('v-slot:') | ||
? 'v-slot:'.length | ||
: 0), ctx.codeFeatures.withoutHighlightAndCompletion, `default`) | ||
])); | ||
if (hasProps) { | ||
yield `)`; | ||
} | ||
yield common_1.endOfLine; | ||
for (const varName of slotBlockVars) { | ||
@@ -337,3 +336,3 @@ ctx.addLocalVariable(varName); | ||
if (isStatic && slotDir && !slotDir.arg) { | ||
yield `${componentCtxVar}.slots!['`; | ||
yield `__VLS_nonNullable(${componentCtxVar}.slots)['`; | ||
yield [ | ||
@@ -340,0 +339,0 @@ '', |
@@ -21,3 +21,3 @@ "use strict"; | ||
&& node.tagType !== CompilerDOM.ElementTypes.TEMPLATE) { | ||
yield `(${componentCtxVar}.slots!).`; | ||
yield `__VLS_nonNullable(${componentCtxVar}.slots).`; | ||
yield* (0, common_1.wrapWith)(node.children[0].loc.start.offset, node.children[node.children.length - 1].loc.end.offset, ctx.codeFeatures.navigation, `default`); | ||
@@ -24,0 +24,0 @@ yield common_1.endOfLine; |
@@ -147,3 +147,3 @@ "use strict"; | ||
} | ||
else if (ts.isIdentifier(child_2)) { | ||
else if (isPropertyAccessOrId(ts, child_2)) { | ||
result = false; | ||
@@ -160,2 +160,11 @@ } | ||
} | ||
function isPropertyAccessOrId(ts, node) { | ||
if (ts.isIdentifier(node)) { | ||
return true; | ||
} | ||
if (ts.isPropertyAccessExpression(node)) { | ||
return isPropertyAccessOrId(ts, node.expression); | ||
} | ||
return false; | ||
} | ||
//# sourceMappingURL=elementEvents.js.map |
@@ -89,3 +89,3 @@ "use strict"; | ||
}, 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), `)`); | ||
: (0, common_1.wrapWith)(prop.loc.start.offset, prop.loc.start.offset + 'v-model'.length, ctx.codeFeatures.verification, propName)), `: (`, ...genereatePropExp(options, ctx, prop.exp, ctx.codeFeatures.all, prop.arg?.loc.start.offset === prop.exp?.loc.start.offset, enableCodeFeatures), `)`); | ||
if (!enableCodeFeatures) { | ||
@@ -92,0 +92,0 @@ yield (0, muggle_string_1.toString)([...codes]); |
"use strict"; | ||
/// <reference types="@volar/typescript" /> | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createVueLanguagePlugin = createVueLanguagePlugin; | ||
const language_core_1 = require("@volar/language-core"); | ||
const CompilerDOM = require("@vue/compiler-dom"); | ||
const plugins_1 = require("./plugins"); | ||
const vueFile_1 = require("./virtualFile/vueFile"); | ||
const CompilerDOM = require("@vue/compiler-dom"); | ||
const CompilerVue2 = require("./utils/vue2TemplateCompiler"); | ||
const file_html_1 = require("./plugins/file-html"); | ||
const file_md_1 = require("./plugins/file-md"); | ||
const file_vue_1 = require("./plugins/file-vue"); | ||
const CompilerVue2 = require("./utils/vue2TemplateCompiler"); | ||
const vueFile_1 = require("./virtualFile/vueFile"); | ||
const normalFileRegistries = []; | ||
@@ -13,0 +14,0 @@ const holderFileRegistries = []; |
@@ -1,27 +0,3 @@ | ||
import { pluginVersion, type VueLanguagePlugin } from './types'; | ||
import { VueLanguagePlugin } from './types'; | ||
export * from './plugins/shared'; | ||
export declare function getBasePlugins(pluginContext: Parameters<VueLanguagePlugin>[0]): { | ||
version: typeof pluginVersion; | ||
name?: string; | ||
order?: number; | ||
requiredCompilerOptions?: string[]; | ||
parseSFC?(fileName: string, content: string): import("@vue/compiler-sfc").SFCParseResult | undefined; | ||
updateSFC?(oldResult: import("@vue/compiler-sfc").SFCParseResult, textChange: { | ||
start: number; | ||
end: number; | ||
newText: string; | ||
}): import("@vue/compiler-sfc").SFCParseResult | undefined; | ||
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; | ||
updateSFCTemplate?(oldResult: import("@vue/compiler-dom").CodegenResult, textChange: { | ||
start: number; | ||
end: number; | ||
newText: string; | ||
}): import("@vue/compiler-dom").CodegenResult | undefined; | ||
getEmbeddedCodes?(fileName: string, sfc: import("./types").Sfc): { | ||
id: string; | ||
lang: string; | ||
}[]; | ||
resolveEmbeddedCode?(fileName: string, sfc: import("./types").Sfc, embeddedFile: import("./types").VueEmbeddedCode): void; | ||
}[]; | ||
export declare function createPlugins(pluginContext: Parameters<VueLanguagePlugin>[0]): import("./types").VueLanguagePluginReturn[]; |
@@ -17,3 +17,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getBasePlugins = getBasePlugins; | ||
exports.createPlugins = createPlugins; | ||
const file_html_1 = require("./plugins/file-html"); | ||
const file_md_1 = require("./plugins/file-md"); | ||
const file_vue_1 = require("./plugins/file-vue"); | ||
const vue_script_js_1 = require("./plugins/vue-script-js"); | ||
const vue_sfc_customblocks_1 = require("./plugins/vue-sfc-customblocks"); | ||
@@ -23,3 +27,2 @@ const vue_sfc_scripts_1 = require("./plugins/vue-sfc-scripts"); | ||
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,4 +34,7 @@ const vue_template_inline_css_1 = require("./plugins/vue-template-inline-css"); | ||
__exportStar(require("./plugins/shared"), exports); | ||
function getBasePlugins(pluginContext) { | ||
function createPlugins(pluginContext) { | ||
const plugins = [ | ||
file_vue_1.default, | ||
file_md_1.default, | ||
file_html_1.default, | ||
vue_script_js_1.default, | ||
@@ -46,6 +52,14 @@ vue_template_html_1.default, | ||
const pluginInstances = plugins | ||
.map(plugin => { | ||
.flatMap(plugin => { | ||
try { | ||
const instance = plugin(pluginContext); | ||
instance.name ??= plugin.__moduleName; | ||
const moduleName = plugin.__moduleName; | ||
if (Array.isArray(instance)) { | ||
for (let i = 0; i < instance.length; i++) { | ||
instance[i].name ??= `${moduleName} (${i})`; | ||
} | ||
} | ||
else { | ||
instance.name ??= moduleName; | ||
} | ||
return instance; | ||
@@ -57,3 +71,3 @@ } | ||
}) | ||
.filter((plugin) => !!plugin) | ||
.filter(plugin => !!plugin) | ||
.sort((a, b) => { | ||
@@ -65,9 +79,9 @@ const aOrder = a.order ?? 0; | ||
return pluginInstances.filter(plugin => { | ||
const valid = plugin.version === types_1.pluginVersion; | ||
if (!valid) { | ||
console.warn(`[Vue] Plugin ${JSON.stringify(plugin.name)} API version incompatible, expected "${types_1.pluginVersion}" but got "${plugin.version}".`); | ||
if (!types_1.validVersions.includes(plugin.version)) { | ||
console.warn(`[Vue] Plugin ${plugin.name} is not compatible with the current Vue language tools version. (version: ${plugin.version}, supported versions: ${JSON.stringify(types_1.validVersions)})`); | ||
return false; | ||
} | ||
return valid; | ||
return true; | ||
}); | ||
} | ||
//# sourceMappingURL=plugins.js.map |
@@ -5,6 +5,17 @@ "use strict"; | ||
const langReg = /\blang\s*=\s*(['\"]?)(\S*)\b\1/; | ||
const plugin = () => { | ||
const plugin = ({ vueCompilerOptions }) => { | ||
return { | ||
version: 2, | ||
parseSFC(fileName, content) { | ||
version: 2.1, | ||
getLanguageId(fileName) { | ||
if (vueCompilerOptions.petiteVueExtensions.some(ext => fileName.endsWith(ext))) { | ||
return 'html'; | ||
} | ||
}, | ||
isValidFile(_fileName, languageId) { | ||
return languageId === 'html'; | ||
}, | ||
parseSFC2(fileName, languageId, content) { | ||
if (languageId !== 'html') { | ||
return; | ||
} | ||
let sfc = { | ||
@@ -11,0 +22,0 @@ descriptor: { |
@@ -14,6 +14,17 @@ "use strict"; | ||
const codeSnippetImportReg = /^\s*<<<\s*.+/gm; | ||
const plugin = () => { | ||
const plugin = ({ vueCompilerOptions }) => { | ||
return { | ||
version: 2, | ||
parseSFC(_fileName, content) { | ||
version: 2.1, | ||
getLanguageId(fileName) { | ||
if (vueCompilerOptions.vitePressExtensions.some(ext => fileName.endsWith(ext))) { | ||
return 'markdown'; | ||
} | ||
}, | ||
isValidFile(_fileName, languageId) { | ||
return languageId === 'markdown'; | ||
}, | ||
parseSFC2(_fileName, languageId, content) { | ||
if (languageId !== 'markdown') { | ||
return; | ||
} | ||
content = content | ||
@@ -20,0 +31,0 @@ // code block |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const parseSfc_1 = require("../utils/parseSfc"); | ||
const plugin = _ctx => { | ||
const plugin = ({ vueCompilerOptions }) => { | ||
return { | ||
version: 2, | ||
parseSFC(_fileName, content) { | ||
version: 2.1, | ||
getLanguageId(fileName) { | ||
if (vueCompilerOptions.extensions.some(ext => fileName.endsWith(ext))) { | ||
return 'vue'; | ||
} | ||
}, | ||
isValidFile(_fileName, languageId) { | ||
return languageId === 'vue'; | ||
}, | ||
parseSFC2(_fileName, languageId, content) { | ||
if (languageId !== 'vue') { | ||
return; | ||
} | ||
return (0, parseSfc_1.parse)(content); | ||
@@ -9,0 +20,0 @@ }, |
@@ -5,3 +5,3 @@ "use strict"; | ||
return { | ||
version: 2, | ||
version: 2.1, | ||
compileSFCScript(lang, script) { | ||
@@ -8,0 +8,0 @@ if (lang === 'js' || lang === 'ts' || lang === 'jsx' || lang === 'tsx') { |
@@ -6,3 +6,3 @@ "use strict"; | ||
return { | ||
version: 2, | ||
version: 2.1, | ||
getEmbeddedCodes(_fileName, sfc) { | ||
@@ -9,0 +9,0 @@ return sfc.customBlocks.map((customBlock, i) => ({ |
@@ -5,3 +5,3 @@ "use strict"; | ||
return { | ||
version: 2, | ||
version: 2.1, | ||
getEmbeddedCodes(_fileName, sfc) { | ||
@@ -8,0 +8,0 @@ const names = []; |
@@ -6,3 +6,3 @@ "use strict"; | ||
return { | ||
version: 2, | ||
version: 2.1, | ||
getEmbeddedCodes(_fileName, sfc) { | ||
@@ -9,0 +9,0 @@ const result = []; |
@@ -6,3 +6,3 @@ "use strict"; | ||
return { | ||
version: 2, | ||
version: 2.1, | ||
getEmbeddedCodes(_fileName, sfc) { | ||
@@ -9,0 +9,0 @@ if (sfc.template) { |
@@ -5,3 +5,3 @@ "use strict"; | ||
return { | ||
version: 2, | ||
version: 2.1, | ||
compileSFCTemplate(lang, template, options) { | ||
@@ -8,0 +8,0 @@ if (lang === 'html' || lang === 'md') { |
@@ -13,3 +13,3 @@ "use strict"; | ||
return { | ||
version: 2, | ||
version: 2.1, | ||
getEmbeddedCodes(_fileName, sfc) { | ||
@@ -16,0 +16,0 @@ if (!sfc.template?.ast) { |
@@ -25,3 +25,3 @@ "use strict"; | ||
return { | ||
version: 2, | ||
version: 2.1, | ||
getEmbeddedCodes(_fileName, sfc) { | ||
@@ -28,0 +28,0 @@ if (!sfc.template?.ast) { |
@@ -13,3 +13,3 @@ "use strict"; | ||
return { | ||
version: 2, | ||
version: 2.1, | ||
requiredCompilerOptions: [ | ||
@@ -16,0 +16,0 @@ 'noPropertyAccessFromIndexSignature', |
@@ -51,17 +51,12 @@ import type { CodeInformation } from '@volar/language-core'; | ||
} | ||
export declare const pluginVersion = 2; | ||
export type VueLanguagePlugin = (ctx: { | ||
modules: { | ||
typescript: typeof import('typescript'); | ||
'@vue/compiler-dom': typeof import('@vue/compiler-dom'); | ||
}; | ||
compilerOptions: ts.CompilerOptions; | ||
vueCompilerOptions: VueCompilerOptions; | ||
globalTypesHolder: string | undefined; | ||
}) => { | ||
version: typeof pluginVersion; | ||
export declare const validVersions: readonly [2, 2.1]; | ||
export type VueLanguagePluginReturn = { | ||
version: typeof validVersions[number]; | ||
name?: string; | ||
order?: number; | ||
requiredCompilerOptions?: string[]; | ||
getLanguageId?(fileName: string): string | undefined; | ||
isValidFile?(fileName: string, languageId: string): boolean; | ||
parseSFC?(fileName: string, content: string): SFCParseResult | undefined; | ||
parseSFC2?(fileName: string, languageId: string, content: string): SFCParseResult | undefined; | ||
updateSFC?(oldResult: SFCParseResult, textChange: { | ||
@@ -86,2 +81,11 @@ start: number; | ||
}; | ||
export type VueLanguagePlugin = (ctx: { | ||
modules: { | ||
typescript: typeof import('typescript'); | ||
'@vue/compiler-dom': typeof import('@vue/compiler-dom'); | ||
}; | ||
compilerOptions: ts.CompilerOptions; | ||
vueCompilerOptions: VueCompilerOptions; | ||
globalTypesHolder: string | undefined; | ||
}) => VueLanguagePluginReturn | VueLanguagePluginReturn[]; | ||
export interface SfcBlock { | ||
@@ -88,0 +92,0 @@ name: string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.pluginVersion = void 0; | ||
exports.pluginVersion = 2; | ||
exports.validVersions = void 0; | ||
exports.validVersions = [2, 2.1]; | ||
//# sourceMappingURL=types.js.map |
@@ -7,2 +7,3 @@ "use strict"; | ||
const path = require("path-browserify"); | ||
const languagePlugin_1 = require("../languagePlugin"); | ||
function createParsedCommandLineByJson(ts, parseConfigHost, rootDir, json, configFileName = rootDir + '/jsconfig.json') { | ||
@@ -22,7 +23,4 @@ const proxyHost = proxyParseConfigHostForExtendConfigPaths(parseConfigHost); | ||
const resolvedVueOptions = resolveVueCompilerOptions(vueOptions); | ||
const parsed = ts.parseJsonConfigFileContent(json, proxyHost.host, rootDir, {}, configFileName, undefined, [ | ||
...resolvedVueOptions.extensions, | ||
...resolvedVueOptions.vitePressExtensions, | ||
...resolvedVueOptions.petiteVueExtensions, | ||
].map(extension => ({ | ||
const parsed = ts.parseJsonConfigFileContent(json, proxyHost.host, rootDir, {}, configFileName, undefined, (0, languagePlugin_1.getAllExtensions)(resolvedVueOptions) | ||
.map(extension => ({ | ||
extension: extension.slice(1), | ||
@@ -57,7 +55,4 @@ isMixedContent: true, | ||
const resolvedVueOptions = resolveVueCompilerOptions(vueOptions); | ||
const parsed = ts.parseJsonSourceFileConfigFileContent(config, proxyHost.host, path.dirname(tsConfigPath), {}, tsConfigPath, undefined, [ | ||
...resolvedVueOptions.extensions, | ||
...resolvedVueOptions.vitePressExtensions, | ||
...resolvedVueOptions.petiteVueExtensions, | ||
].map(extension => ({ | ||
const parsed = ts.parseJsonSourceFileConfigFileContent(config, proxyHost.host, path.dirname(tsConfigPath), {}, tsConfigPath, undefined, (0, languagePlugin_1.getAllExtensions)(resolvedVueOptions) | ||
.map(extension => ({ | ||
extension: extension.slice(1), | ||
@@ -135,10 +130,3 @@ isMixedContent: true, | ||
const plugin = require(resolvedPath); | ||
if (Array.isArray(plugin)) { | ||
for (let i = 0; i < plugin.length; i++) { | ||
plugin[i].__moduleName = `${pluginPath} (${i})`; | ||
} | ||
} | ||
else { | ||
plugin.__moduleName = pluginPath; | ||
} | ||
plugin.__moduleName = pluginPath; | ||
return plugin; | ||
@@ -154,4 +142,3 @@ } | ||
return []; | ||
}) | ||
.flat(Infinity); | ||
}); | ||
result.plugins = plugins; | ||
@@ -158,0 +145,0 @@ } |
import type { VirtualCode } from '@volar/language-core'; | ||
import type { Sfc, VueLanguagePlugin } from '../types'; | ||
export declare function computedFiles(plugins: ReturnType<VueLanguagePlugin>[], fileName: string, sfc: Sfc): () => VirtualCode[]; | ||
import type { Sfc, VueLanguagePluginReturn } from '../types'; | ||
export declare function computedFiles(plugins: VueLanguagePluginReturn[], fileName: string, sfc: Sfc): () => VirtualCode[]; | ||
export declare function resolveCommonLanguageId(lang: string): string; |
import type { SFCParseResult } from '@vue/compiler-sfc'; | ||
import type * as ts from 'typescript'; | ||
import type { Sfc, VueLanguagePlugin } from '../types'; | ||
export declare function computedSfc(ts: typeof import('typescript'), plugins: ReturnType<VueLanguagePlugin>[], fileName: string, snapshot: () => ts.IScriptSnapshot, parsed: () => SFCParseResult | undefined): Sfc; | ||
import type { Sfc, VueLanguagePluginReturn } from '../types'; | ||
export declare function computedSfc(ts: typeof import('typescript'), plugins: VueLanguagePluginReturn[], fileName: string, snapshot: () => ts.IScriptSnapshot, parsed: () => SFCParseResult | undefined): Sfc; |
import type { SFCParseResult } from '@vue/compiler-sfc'; | ||
import type * as ts from 'typescript'; | ||
import type { VueLanguagePlugin } from '../types'; | ||
export declare function computedVueSfc(plugins: ReturnType<VueLanguagePlugin>[], fileName: string, snapshot: () => ts.IScriptSnapshot): () => SFCParseResult | undefined; | ||
import type { VueLanguagePluginReturn } from '../types'; | ||
export declare function computedVueSfc(plugins: VueLanguagePluginReturn[], fileName: string, languageId: string, snapshot: () => ts.IScriptSnapshot): () => SFCParseResult | undefined; |
@@ -5,3 +5,3 @@ "use strict"; | ||
const computeds_1 = require("computeds"); | ||
function computedVueSfc(plugins, fileName, snapshot) { | ||
function computedVueSfc(plugins, fileName, languageId, snapshot) { | ||
let cache; | ||
@@ -27,3 +27,4 @@ return (0, computeds_1.computed)(() => { | ||
for (const plugin of plugins) { | ||
const sfc = plugin.parseSFC?.(fileName, snapshot().getText(0, snapshot().getLength())); | ||
const sfc = plugin.parseSFC?.(fileName, snapshot().getText(0, snapshot().getLength())) | ||
?? plugin.parseSFC2?.(fileName, languageId, snapshot().getText(0, snapshot().getLength())); | ||
if (sfc) { | ||
@@ -30,0 +31,0 @@ if (!sfc.errors.length) { |
import type { VirtualCode } from '@volar/language-core'; | ||
import { Signal } from 'computeds'; | ||
import type * as ts from 'typescript'; | ||
import type { VueCompilerOptions, VueLanguagePlugin } from '../types'; | ||
import type { VueCompilerOptions, VueLanguagePluginReturn } from '../types'; | ||
export declare class VueVirtualCode implements VirtualCode { | ||
@@ -10,3 +10,3 @@ fileName: string; | ||
vueCompilerOptions: VueCompilerOptions; | ||
plugins: ReturnType<VueLanguagePlugin>[]; | ||
plugins: VueLanguagePluginReturn[]; | ||
ts: typeof import('typescript'); | ||
@@ -22,4 +22,4 @@ id: string; | ||
get mappings(): import("@volar/language-core").CodeMapping[]; | ||
constructor(fileName: string, languageId: string, initSnapshot: ts.IScriptSnapshot, vueCompilerOptions: VueCompilerOptions, plugins: ReturnType<VueLanguagePlugin>[], ts: typeof import('typescript')); | ||
constructor(fileName: string, languageId: string, initSnapshot: ts.IScriptSnapshot, vueCompilerOptions: VueCompilerOptions, plugins: VueLanguagePluginReturn[], ts: typeof import('typescript')); | ||
update(newSnapshot: ts.IScriptSnapshot): void; | ||
} |
@@ -30,3 +30,3 @@ "use strict"; | ||
// computeds | ||
this.getVueSfc = (0, computedVueSfc_1.computedVueSfc)(this.plugins, this.fileName, () => this._snapshot()); | ||
this.getVueSfc = (0, computedVueSfc_1.computedVueSfc)(this.plugins, this.fileName, this.languageId, () => this._snapshot()); | ||
this.sfc = (0, computedSfc_1.computedSfc)(this.ts, this.plugins, this.fileName, () => this._snapshot(), this.getVueSfc); | ||
@@ -33,0 +33,0 @@ this.getMappings = (0, computedMappings_1.computedMappings)(() => this._snapshot(), this.sfc); |
{ | ||
"name": "@vue/language-core", | ||
"version": "2.0.26", | ||
"version": "2.0.28", | ||
"license": "MIT", | ||
@@ -15,3 +15,3 @@ "files": [ | ||
"dependencies": { | ||
"@volar/language-core": "~2.4.0-alpha.15", | ||
"@volar/language-core": "~2.4.0-alpha.18", | ||
"@vue/compiler-dom": "^3.4.0", | ||
@@ -29,3 +29,3 @@ "@vue/shared": "^3.4.0", | ||
"@types/path-browserify": "^1.0.1", | ||
"@volar/typescript": "~2.4.0-alpha.15", | ||
"@volar/typescript": "~2.4.0-alpha.18", | ||
"@vue/compiler-sfc": "^3.4.0" | ||
@@ -41,3 +41,3 @@ }, | ||
}, | ||
"gitHead": "47924f61e9409501d11ab04e9d3417cc5c86232c" | ||
"gitHead": "0cdbd70996f4fc7ac8d511b0d9fdbe20b7a4f6a3" | ||
} |
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
307678
122
6882