@vue/language-core
Advanced tools
Comparing version
export * from './lib/codegen/globalTypes'; | ||
export * from './lib/codegen/template'; | ||
export * from './lib/codegen/utils'; | ||
export * from './lib/languagePlugin'; | ||
@@ -8,2 +7,3 @@ export * from './lib/parsers/scriptSetupRanges'; | ||
export * from './lib/types'; | ||
export * from './lib/utils/collectBindings'; | ||
export * from './lib/utils/parseSfc'; | ||
@@ -10,0 +10,0 @@ export * from './lib/utils/shared'; |
@@ -20,3 +20,2 @@ "use strict"; | ||
__exportStar(require("./lib/codegen/template"), exports); | ||
__exportStar(require("./lib/codegen/utils"), exports); | ||
__exportStar(require("./lib/languagePlugin"), exports); | ||
@@ -26,2 +25,3 @@ __exportStar(require("./lib/parsers/scriptSetupRanges"), exports); | ||
__exportStar(require("./lib/types"), exports); | ||
__exportStar(require("./lib/utils/collectBindings"), exports); | ||
__exportStar(require("./lib/utils/parseSfc"), exports); | ||
@@ -28,0 +28,0 @@ __exportStar(require("./lib/utils/shared"), exports); |
@@ -90,4 +90,19 @@ import type { VueCodeInformation } from '../types'; | ||
}; | ||
doNotReportTs2339AndTs2551: { | ||
verification: { | ||
shouldReport: (_source: string | undefined, code: string | number | undefined) => boolean; | ||
}; | ||
}; | ||
doNotReportTs2353AndTs2561: { | ||
verification: { | ||
shouldReport: (_source: string | undefined, code: string | number | undefined) => boolean; | ||
}; | ||
}; | ||
doNotReportTs6133: { | ||
verification: { | ||
shouldReport: (_source: string | undefined, code: string | number | undefined) => boolean; | ||
}; | ||
}; | ||
}; | ||
export declare const codeFeatures: { [K in keyof typeof raw]: VueCodeInformation; }; | ||
export {}; |
@@ -76,4 +76,24 @@ "use strict"; | ||
}, | ||
doNotReportTs2339AndTs2551: { | ||
verification: { | ||
// https://typescript.tv/errors/#ts2339 | ||
// https://typescript.tv/errors/#ts2551 | ||
shouldReport: (_source, code) => String(code) !== '2339' && String(code) !== '2551', | ||
}, | ||
}, | ||
doNotReportTs2353AndTs2561: { | ||
verification: { | ||
// https://typescript.tv/errors/#ts2353 | ||
// https://typescript.tv/errors/#ts2561 | ||
shouldReport: (_source, code) => String(code) !== '2353' && String(code) !== '2561', | ||
}, | ||
}, | ||
doNotReportTs6133: { | ||
verification: { | ||
// https://typescript.tv/errors/#ts6133 | ||
shouldReport: (_source, code) => String(code) !== '6133', | ||
}, | ||
}, | ||
}; | ||
exports.codeFeatures = raw; | ||
//# sourceMappingURL=codeFeatures.js.map |
import type { VueCompilerOptions } from '../types'; | ||
export declare function getGlobalTypesFileName({ lib, target, checkUnknownProps, checkUnknownEvents, checkUnknownComponents, }: VueCompilerOptions): string; | ||
export declare function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvents, checkUnknownComponents, }: VueCompilerOptions): string; | ||
export declare function getGlobalTypesFileName(options: VueCompilerOptions): string; | ||
export declare function generateGlobalTypes(options: VueCompilerOptions): string; |
@@ -6,12 +6,11 @@ "use strict"; | ||
const shared_1 = require("../utils/shared"); | ||
function getGlobalTypesFileName({ lib, target, checkUnknownProps, checkUnknownEvents, checkUnknownComponents, }) { | ||
function getGlobalTypesFileName(options) { | ||
return [ | ||
lib, | ||
target, | ||
checkUnknownProps, | ||
checkUnknownEvents, | ||
checkUnknownComponents, | ||
options.lib, | ||
options.target, | ||
options.checkUnknownProps, | ||
].map(v => (typeof v === 'boolean' ? Number(v) : v)).join('_') + '.d.ts'; | ||
} | ||
function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvents, checkUnknownComponents, }) { | ||
function generateGlobalTypes(options) { | ||
const { lib, target, checkUnknownProps } = options; | ||
const fnPropsType = `(T extends { $props: infer Props } ? Props : {})${checkUnknownProps ? '' : ' & Record<string, unknown>'}`; | ||
@@ -54,3 +53,3 @@ let text = `// @ts-nocheck\nexport {};\n`; | ||
N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N3] } : | ||
${checkUnknownComponents ? '{}' : '{ [K in N0]: unknown }'}; | ||
{}; | ||
type __VLS_FunctionalComponentCtx<T, K> = __VLS_PickNotAny<'__ctx' extends keyof __VLS_PickNotAny<K, {}> | ||
@@ -66,8 +65,8 @@ ? K extends { __ctx?: infer Ctx } ? NonNullable<Ctx> : never : any | ||
__ctx?: { | ||
attrs?: any, | ||
slots?: T extends { ${(0, shared_1.getSlotsPropertyName)(target)}: infer Slots } ? Slots : Record<string, any>, | ||
emit?: T extends { $emit: infer Emit } ? Emit : {}, | ||
props?: ${fnPropsType}, | ||
expose?: (exposed: T) => void, | ||
} | ||
attrs?: any; | ||
slots?: T extends { ${(0, shared_1.getSlotsPropertyName)(target)}: infer Slots } ? Slots : Record<string, any>; | ||
emit?: T extends { $emit: infer Emit } ? Emit : {}; | ||
props?: ${fnPropsType}; | ||
expose?: (exposed: T) => void; | ||
}; | ||
}; | ||
@@ -81,11 +80,15 @@ type __VLS_IsFunction<T, K> = K extends keyof T | ||
: false; | ||
type __VLS_NormalizeComponentEvent<Props, Emits, onEvent extends keyof Props, Event extends keyof Emits, CamelizedEvent extends keyof Emits> = ( | ||
__VLS_IsFunction<Props, onEvent> extends true | ||
? Props | ||
: __VLS_IsFunction<Emits, Event> extends true | ||
? { [K in onEvent]?: Emits[Event] } | ||
: __VLS_IsFunction<Emits, CamelizedEvent> extends true | ||
? { [K in onEvent]?: Emits[CamelizedEvent] } | ||
: Props | ||
)${checkUnknownEvents ? '' : ' & Record<string, unknown>'}; | ||
type __VLS_NormalizeComponentEvent< | ||
Props, | ||
Emits, | ||
onEvent extends keyof Props, | ||
Event extends keyof Emits, | ||
CamelizedEvent extends keyof Emits, | ||
> = __VLS_IsFunction<Props, onEvent> extends true | ||
? Props | ||
: __VLS_IsFunction<Emits, Event> extends true | ||
? { [K in onEvent]?: Emits[Event] } | ||
: __VLS_IsFunction<Emits, CamelizedEvent> extends true | ||
? { [K in onEvent]?: Emits[CamelizedEvent] } | ||
: Props; | ||
// fix https://github.com/vuejs/language-tools/issues/926 | ||
@@ -157,3 +160,3 @@ type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never; | ||
function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): 2 extends Parameters<T>['length'] ? [any] : []; | ||
function __VLS_asFunctionalElement<T>(tag: T, endTag?: T): (attrs: T${checkUnknownComponents ? '' : ' & Record<string, unknown>'}) => void; | ||
function __VLS_asFunctionalElement<T>(tag: T, endTag?: T): (attrs: T${checkUnknownProps ? '' : ' & Record<string, unknown>'}) => void; | ||
function __VLS_asFunctionalSlot<S>(slot: S): S extends () => infer R ? (props: {}) => R : NonNullable<S>; | ||
@@ -160,0 +163,0 @@ function __VLS_tryAsConstant<const T>(t: T): T; |
@@ -251,6 +251,5 @@ "use strict"; | ||
if (syntax) { | ||
if (!options.vueCompilerOptions.skipTemplateCodegen | ||
&& (scriptSetupRanges.defineSlots | ||
|| options.templateCodegen?.slots.length | ||
|| options.templateCodegen?.dynamicSlots.length)) { | ||
if (scriptSetupRanges.defineSlots | ||
|| options.templateCodegen?.slots.length | ||
|| options.templateCodegen?.dynamicSlots.length) { | ||
yield `const __VLS_component = `; | ||
@@ -257,0 +256,0 @@ yield* (0, component_1.generateComponent)(options, ctx, scriptSetup, scriptSetupRanges); |
@@ -133,2 +133,5 @@ import * as CompilerDOM from '@vue/compiler-dom'; | ||
withoutSemantic: VueCodeInformation; | ||
doNotReportTs2339AndTs2551: VueCodeInformation; | ||
doNotReportTs2353AndTs2561: VueCodeInformation; | ||
doNotReportTs6133: VueCodeInformation; | ||
}; | ||
@@ -135,0 +138,0 @@ resolveCodeFeatures: (features: VueCodeInformation) => VueCodeInformation; |
@@ -113,3 +113,8 @@ "use strict"; | ||
yield `>).`; | ||
yield* generateCanonicalComponentName(node.tag, tagOffsets[0], ctx.codeFeatures.withoutHighlightAndCompletionAndNavigation); | ||
yield* generateCanonicalComponentName(node.tag, tagOffsets[0], ctx.resolveCodeFeatures({ | ||
...codeFeatures_1.codeFeatures.semanticWithoutHighlight, | ||
...options.vueCompilerOptions.checkUnknownComponents | ||
? codeFeatures_1.codeFeatures.verification | ||
: codeFeatures_1.codeFeatures.doNotReportTs2339AndTs2551, | ||
})); | ||
yield `${utils_1.endOfLine}`; | ||
@@ -144,10 +149,3 @@ const camelizedTag = (0, shared_1.camelize)(node.tag); | ||
yield `const `; | ||
yield* (0, wrapWith_1.wrapWith)(node.loc.start.offset, node.loc.end.offset, ctx.resolveCodeFeatures({ | ||
verification: { | ||
shouldReport(_source, code) { | ||
// https://typescript.tv/errors/#ts6133 | ||
return String(code) !== '6133'; | ||
}, | ||
}, | ||
}), componentVNodeVar); | ||
yield* (0, wrapWith_1.wrapWith)(node.loc.start.offset, node.loc.end.offset, ctx.codeFeatures.doNotReportTs6133, componentVNodeVar); | ||
yield ` = ${componentFunctionalVar}`; | ||
@@ -154,0 +152,0 @@ yield* generateComponentGeneric(ctx); |
@@ -7,5 +7,5 @@ import * as CompilerDOM from '@vue/compiler-dom'; | ||
export declare function generateElementEvents(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, componentOriginalVar: string, componentFunctionalVar: string, componentVNodeVar: string, componentCtxVar: string): Generator<Code>; | ||
export declare function generateEventArg(ctx: TemplateCodegenContext, name: string, start: number, directive?: string, features?: VueCodeInformation): Generator<Code>; | ||
export declare function generateEventArg(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, name: string, start: number, directive?: string, features?: VueCodeInformation): Generator<Code>; | ||
export declare function generateEventExpression(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode): Generator<Code>; | ||
export declare function generateModelEventExpression(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode): Generator<Code>; | ||
export declare function isCompoundExpression(ts: typeof import('typescript'), ast: ts.SourceFile): boolean; |
@@ -10,2 +10,3 @@ "use strict"; | ||
const shared_1 = require("@vue/shared"); | ||
const codeFeatures_1 = require("../codeFeatures"); | ||
const utils_1 = require("../utils"); | ||
@@ -52,3 +53,3 @@ const camelized_1 = require("../utils/camelized"); | ||
yield `{ `; | ||
yield* generateEventArg(ctx, source, start, emitPrefix.slice(0, -1), ctx.codeFeatures.navigation); | ||
yield* generateEventArg(options, ctx, source, start, emitPrefix.slice(0, -1), ctx.codeFeatures.navigation); | ||
yield `: {} as any } as typeof ${emitsVar},${utils_1.newLine}`; | ||
@@ -58,3 +59,3 @@ } | ||
if (prop.name === 'on') { | ||
yield* generateEventArg(ctx, source, start, propPrefix.slice(0, -1)); | ||
yield* generateEventArg(options, ctx, source, start, propPrefix.slice(0, -1)); | ||
yield `: `; | ||
@@ -71,6 +72,10 @@ yield* generateEventExpression(options, ctx, prop); | ||
} | ||
function* generateEventArg(ctx, name, start, directive = 'on', features = { | ||
...ctx.codeFeatures.withoutHighlightAndCompletion, | ||
...ctx.codeFeatures.navigationWithoutRename, | ||
}) { | ||
function* generateEventArg(options, ctx, name, start, directive = 'on', features) { | ||
features ??= ctx.resolveCodeFeatures({ | ||
...codeFeatures_1.codeFeatures.semanticWithoutHighlight, | ||
...codeFeatures_1.codeFeatures.navigationWithoutRename, | ||
...options.vueCompilerOptions.checkUnknownEvents | ||
? codeFeatures_1.codeFeatures.verification | ||
: codeFeatures_1.codeFeatures.doNotReportTs2353AndTs2561, | ||
}); | ||
if (directive.length) { | ||
@@ -77,0 +82,0 @@ name = (0, shared_1.capitalize)(name); |
@@ -30,3 +30,3 @@ "use strict"; | ||
yield `...{ `; | ||
yield* (0, elementEvents_1.generateEventArg)(ctx, prop.arg.loc.source, prop.arg.loc.start.offset); | ||
yield* (0, elementEvents_1.generateEventArg)(options, ctx, prop.arg.loc.source, prop.arg.loc.start.offset); | ||
yield `: `; | ||
@@ -227,12 +227,5 @@ yield* (0, elementEvents_1.generateEventExpression)(options, ctx, prop); | ||
...codeFeatures_1.codeFeatures.withoutHighlightAndCompletion, | ||
verification: strictPropsCheck || { | ||
shouldReport(_source, code) { | ||
// https://typescript.tv/errors/#ts2353 | ||
// https://typescript.tv/errors/#ts2561 | ||
if (String(code) === '2353' || String(code) === '2561') { | ||
return false; | ||
} | ||
return true; | ||
}, | ||
}, | ||
...strictPropsCheck | ||
? codeFeatures_1.codeFeatures.verification | ||
: codeFeatures_1.codeFeatures.doNotReportTs2353AndTs2561, | ||
}); | ||
@@ -239,0 +232,0 @@ } |
@@ -5,2 +5,3 @@ "use strict"; | ||
const shared_1 = require("@vue/shared"); | ||
const collectBindings_1 = require("../../utils/collectBindings"); | ||
const shared_2 = require("../../utils/shared"); | ||
@@ -137,3 +138,3 @@ const utils_1 = require("../utils"); | ||
else if (ts.isVariableDeclaration(node)) { | ||
const bindingNames = (0, utils_1.collectBindingNames)(ts, node.name, ast); | ||
const bindingNames = (0, collectBindings_1.collectBindingNames)(ts, node.name, ast); | ||
for (const name of bindingNames) { | ||
@@ -200,3 +201,3 @@ ctx.addLocalVariable(name); | ||
for (const param of node.parameters) { | ||
functionArgs.push(...(0, utils_1.collectBindingNames)(ts, param.name, ast)); | ||
functionArgs.push(...(0, collectBindings_1.collectBindingNames)(ts, param.name, ast)); | ||
if (param.type) { | ||
@@ -203,0 +204,0 @@ walkIdentifiersInTypeNode(ts, param.type, cb); |
@@ -6,2 +6,3 @@ "use strict"; | ||
const CompilerDOM = require("@vue/compiler-dom"); | ||
const collectBindings_1 = require("../../utils/collectBindings"); | ||
const utils_1 = require("../utils"); | ||
@@ -17,3 +18,3 @@ const elementChildren_1 = require("./elementChildren"); | ||
const collectAst = (0, utils_1.createTsAst)(options.ts, ctx.inlineTsAsts, `const [${leftExpressionText}]`); | ||
forBlockVars.push(...(0, utils_1.collectBindingNames)(options.ts, collectAst, collectAst)); | ||
forBlockVars.push(...(0, collectBindings_1.collectBindingNames)(options.ts, collectAst, collectAst)); | ||
yield [ | ||
@@ -20,0 +21,0 @@ leftExpressionText, |
@@ -5,2 +5,3 @@ "use strict"; | ||
const CompilerDOM = require("@vue/compiler-dom"); | ||
const collectBindings_1 = require("../../utils/collectBindings"); | ||
const shared_1 = require("../../utils/shared"); | ||
@@ -39,3 +40,3 @@ const utils_1 = require("../utils"); | ||
const slotAst = (0, utils_1.createTsAst)(options.ts, ctx.inlineTsAsts, `(${slotDir.exp.content}) => {}`); | ||
slotBlockVars.push(...(0, utils_1.collectBindingNames)(options.ts, slotAst, slotAst)); | ||
slotBlockVars.push(...(0, collectBindings_1.collectBindingNames)(options.ts, slotAst, slotAst)); | ||
yield* generateSlotParameters(options, ctx, slotAst, slotDir.exp, slotVar); | ||
@@ -42,0 +43,0 @@ } |
@@ -8,14 +8,4 @@ import type * as CompilerDOM from '@vue/compiler-dom'; | ||
export declare const identifierRegex: RegExp; | ||
export declare function collectBindingNames(ts: typeof import('typescript'), node: ts.Node, ast: ts.SourceFile): string[]; | ||
export declare function collectIdentifiers(ts: typeof import('typescript'), node: ts.Node, results?: { | ||
id: ts.Identifier; | ||
isRest: boolean; | ||
initializer: ts.Expression | undefined; | ||
}[], isRest?: boolean, initializer?: ts.Expression | undefined): { | ||
id: ts.Identifier; | ||
isRest: boolean; | ||
initializer: ts.Expression | undefined; | ||
}[]; | ||
export declare function normalizeAttributeValue(node: CompilerDOM.TextNode): [string, number]; | ||
export declare function createTsAst(ts: typeof import('typescript'), inlineTsAsts: Map<string, ts.SourceFile> | undefined, text: string): ts.SourceFile; | ||
export declare function generateSfcBlockSection(block: SfcBlock, start: number, end: number, features: VueCodeInformation): Code; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.identifierRegex = exports.combineLastMapping = exports.endOfLine = exports.newLine = void 0; | ||
exports.collectBindingNames = collectBindingNames; | ||
exports.collectIdentifiers = collectIdentifiers; | ||
exports.normalizeAttributeValue = normalizeAttributeValue; | ||
exports.createTsAst = createTsAst; | ||
exports.generateSfcBlockSection = generateSfcBlockSection; | ||
const shared_1 = require("../../utils/shared"); | ||
exports.newLine = `\n`; | ||
@@ -14,26 +11,2 @@ exports.endOfLine = `;${exports.newLine}`; | ||
exports.identifierRegex = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/; | ||
function collectBindingNames(ts, node, ast) { | ||
return collectIdentifiers(ts, node).map(({ id }) => (0, shared_1.getNodeText)(ts, id, ast)); | ||
} | ||
function collectIdentifiers(ts, node, results = [], isRest = false, initializer = undefined) { | ||
if (ts.isIdentifier(node)) { | ||
results.push({ id: node, isRest, initializer }); | ||
} | ||
else if (ts.isObjectBindingPattern(node)) { | ||
for (const el of node.elements) { | ||
collectIdentifiers(ts, el.name, results, !!el.dotDotDotToken, el.initializer); | ||
} | ||
} | ||
else if (ts.isArrayBindingPattern(node)) { | ||
for (const el of node.elements) { | ||
if (ts.isBindingElement(el)) { | ||
collectIdentifiers(ts, el.name, results, !!el.dotDotDotToken); | ||
} | ||
} | ||
} | ||
else { | ||
ts.forEachChild(node, node => collectIdentifiers(ts, node, results, false)); | ||
} | ||
return results; | ||
} | ||
function normalizeAttributeValue(node) { | ||
@@ -40,0 +13,0 @@ let offset = node.loc.start.offset; |
@@ -75,3 +75,2 @@ import type * as ts from 'typescript'; | ||
}[]; | ||
export declare function findBindingVars(ts: typeof import('typescript'), left: ts.BindingName, ast: ts.SourceFile): TextRange[]; | ||
export {}; |
@@ -5,4 +5,3 @@ "use strict"; | ||
exports.parseBindingRanges = parseBindingRanges; | ||
exports.findBindingVars = findBindingVars; | ||
const utils_1 = require("../codegen/utils"); | ||
const collectBindings_1 = require("../utils/collectBindings"); | ||
const shared_1 = require("../utils/shared"); | ||
@@ -151,3 +150,3 @@ const tsCheckReg = /^\/\/\s*@ts-(?:no)?check($|\s)/; | ||
defineProps.destructured = new Map(); | ||
const identifiers = (0, utils_1.collectIdentifiers)(ts, parent.name); | ||
const identifiers = (0, collectBindings_1.collectBindingIdentifiers)(ts, parent.name); | ||
for (const { id, isRest, initializer } of identifiers) { | ||
@@ -272,4 +271,4 @@ const name = _getNodeText(id); | ||
for (const decl of node.declarationList.declarations) { | ||
const vars = _findBindingVars(decl.name); | ||
bindings.push(...vars.map(range => ({ range }))); | ||
const ranges = (0, collectBindings_1.collectBindingRanges)(ts, decl.name, ast); | ||
bindings.push(...ranges.map(range => ({ range }))); | ||
} | ||
@@ -338,38 +337,3 @@ } | ||
} | ||
function _findBindingVars(left) { | ||
return findBindingVars(ts, left, ast); | ||
} | ||
} | ||
function findBindingVars(ts, left, ast) { | ||
const vars = []; | ||
worker(left); | ||
return vars; | ||
function worker(node) { | ||
if (ts.isIdentifier(node)) { | ||
vars.push((0, shared_1.getStartEnd)(ts, node, ast)); | ||
} | ||
// { ? } = ... | ||
// [ ? ] = ... | ||
else if (ts.isObjectBindingPattern(node) || ts.isArrayBindingPattern(node)) { | ||
for (const property of node.elements) { | ||
if (ts.isBindingElement(property)) { | ||
worker(property.name); | ||
} | ||
} | ||
} | ||
// { foo: ? } = ... | ||
else if (ts.isPropertyAssignment(node)) { | ||
worker(node.initializer); | ||
} | ||
// { foo } = ... | ||
else if (ts.isShorthandPropertyAssignment(node)) { | ||
vars.push((0, shared_1.getStartEnd)(ts, node.name, ast)); | ||
} | ||
// { ...? } = ... | ||
// [ ...? ] = ... | ||
else if (ts.isSpreadAssignment(node) || ts.isSpreadElement(node)) { | ||
worker(node.expression); | ||
} | ||
} | ||
} | ||
function getStatementRange(ts, parents, node, ast) { | ||
@@ -376,0 +340,0 @@ let statementRange; |
@@ -18,5 +18,5 @@ "use strict"; | ||
for (const block of [ | ||
sfc.template, | ||
sfc.script, | ||
sfc.scriptSetup, | ||
sfc.template, | ||
...sfc.styles, | ||
@@ -28,10 +28,3 @@ ...sfc.customBlocks, | ||
} | ||
let content = block.content; | ||
if (content.endsWith('\r\n')) { | ||
content = content.slice(0, -2); | ||
} | ||
else if (content.endsWith('\n')) { | ||
content = content.slice(0, -1); | ||
} | ||
const offset = content.lastIndexOf('\n') + 1; | ||
const offset = block.content.lastIndexOf('\n', block.content.lastIndexOf('\n') - 1) + 1; | ||
// fix folding range end position failed to mapping | ||
@@ -38,0 +31,0 @@ (0, muggle_string_1.replaceSourceRange)(embeddedFile.content, undefined, block.startTagEnd, block.endTagStart, sfc.content.slice(block.startTagEnd, block.startTagEnd + offset), [ |
import type { Code, Sfc, VueLanguagePlugin } from '../types'; | ||
export declare const tsCodegen: WeakMap<Sfc, { | ||
getLang: () => string; | ||
getScriptRanges: () => { | ||
@@ -118,3 +119,3 @@ exportDefault: (import("../types").TextRange & { | ||
} | undefined; | ||
getLang: () => string; | ||
getSetupSlotsAssignName: () => string | undefined; | ||
getGeneratedScript: () => { | ||
@@ -170,2 +171,5 @@ codes: Code[]; | ||
withoutSemantic: import("../types").VueCodeInformation; | ||
doNotReportTs2339AndTs2551: import("../types").VueCodeInformation; | ||
doNotReportTs2353AndTs2561: import("../types").VueCodeInformation; | ||
doNotReportTs6133: import("../types").VueCodeInformation; | ||
}; | ||
@@ -172,0 +176,0 @@ resolveCodeFeatures: (features: import("../types").VueCodeInformation) => import("../types").VueCodeInformation; |
@@ -201,5 +201,6 @@ "use strict"; | ||
return { | ||
getLang, | ||
getScriptRanges, | ||
getScriptSetupRanges, | ||
getLang, | ||
getSetupSlotsAssignName, | ||
getGeneratedScript, | ||
@@ -206,0 +207,0 @@ getGeneratedTemplate, |
@@ -23,3 +23,3 @@ import type { CodeInformation } from '@volar/language-core'; | ||
lib: string; | ||
globalTypesPath: (fileName: string) => string | undefined; | ||
globalTypesPath: (fileName: string) => string | void; | ||
extensions: string[]; | ||
@@ -26,0 +26,0 @@ vitePressExtensions: string[]; |
@@ -182,20 +182,22 @@ "use strict"; | ||
}; | ||
if (this.fileExists && this.globalTypesPath === undefined) { | ||
const fileDirToGlobalTypesPath = new Map(); | ||
resolvedOptions.globalTypesPath = fileName => { | ||
const fileDir = path_browserify_1.posix.dirname(fileName); | ||
if (fileDirToGlobalTypesPath.has(fileDir)) { | ||
return fileDirToGlobalTypesPath.get(fileDir); | ||
} | ||
const root = this.findNodeModulesRoot(fileDir, resolvedOptions.lib); | ||
const result = root | ||
? path_browserify_1.posix.join(root, 'node_modules', '.vue-global-types', (0, globalTypes_1.getGlobalTypesFileName)(resolvedOptions)) | ||
: undefined; | ||
fileDirToGlobalTypesPath.set(fileDir, result); | ||
return result; | ||
}; | ||
if (resolvedOptions.globalTypesPath === shared_1.NOOP) { | ||
if (this.fileExists && this.globalTypesPath === undefined) { | ||
const fileDirToGlobalTypesPath = new Map(); | ||
resolvedOptions.globalTypesPath = fileName => { | ||
const fileDir = path_browserify_1.posix.dirname(fileName); | ||
if (fileDirToGlobalTypesPath.has(fileDir)) { | ||
return fileDirToGlobalTypesPath.get(fileDir); | ||
} | ||
const root = this.findNodeModulesRoot(fileDir, resolvedOptions.lib); | ||
const result = root | ||
? path_browserify_1.posix.join(root, 'node_modules', '.vue-global-types', (0, globalTypes_1.getGlobalTypesFileName)(resolvedOptions)) | ||
: undefined; | ||
fileDirToGlobalTypesPath.set(fileDir, result); | ||
return result; | ||
}; | ||
} | ||
else { | ||
resolvedOptions.globalTypesPath = () => this.globalTypesPath; | ||
} | ||
} | ||
else { | ||
resolvedOptions.globalTypesPath = () => this.globalTypesPath; | ||
} | ||
return resolvedOptions; | ||
@@ -243,3 +245,3 @@ } | ||
lib, | ||
globalTypesPath: () => undefined, | ||
globalTypesPath: shared_1.NOOP, | ||
extensions: ['.vue'], | ||
@@ -246,0 +248,0 @@ vitePressExtensions: [], |
{ | ||
"name": "@vue/language-core", | ||
"version": "3.0.3", | ||
"version": "3.0.4", | ||
"license": "MIT", | ||
@@ -40,3 +40,3 @@ "files": [ | ||
}, | ||
"gitHead": "129f30ff8d8d976abf0431063be5c6c4cf88f0fd" | ||
"gitHead": "148d386f9779c2de64cdcbd35310e03b36943b05" | ||
} |
368870
1.5%156
5.41%8583
1.55%