@vue/language-core
Advanced tools
Comparing version 2.0.7 to 2.0.10
@@ -8,2 +8,3 @@ "use strict"; | ||
const utils_1 = require("./utils"); | ||
const globalTypes_1 = require("./globalTypes"); | ||
function* generate(ts, fileName, script, scriptSetup, styles, // TODO: computed it | ||
@@ -43,3 +44,14 @@ lang, scriptRanges, scriptSetupRanges, templateCodegen, compilerOptions, vueCompilerOptions, globalTypesHolder, getGeneratedLength, linkedCodeMappings = [], codegenStack) { | ||
const bypassDefineComponent = lang === 'js' || lang === 'jsx'; | ||
const _ = codegenStack ? utils_1.withStack : (code) => [code, '']; | ||
const _ = (code) => { | ||
if (typeof code !== 'string') { | ||
code[3].structure = false; | ||
code[3].format = false; | ||
} | ||
if (!codegenStack) { | ||
return [code, '']; | ||
} | ||
else { | ||
return [code, (0, utils_1.getStack)()]; | ||
} | ||
}; | ||
const helperTypes = { | ||
@@ -144,3 +156,3 @@ OmitKeepDiscriminatedUnion: { | ||
if (globalTypesHolder === fileName) { | ||
yield* generateGlobalHelperTypes(); | ||
yield _((0, globalTypes_1.generateGlobalTypes)(vueCompilerOptions)); | ||
} | ||
@@ -155,129 +167,2 @@ yield* generateLocalHelperTypes(); | ||
} | ||
function* generateGlobalHelperTypes() { | ||
const fnPropsType = `(K extends { $props: infer Props } ? Props : any)${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}`; | ||
yield _(` | ||
; declare global { | ||
// @ts-ignore | ||
type __VLS_IntrinsicElements = __VLS_PickNotAny<import('vue/jsx-runtime').JSX.IntrinsicElements, __VLS_PickNotAny<JSX.IntrinsicElements, Record<string, any>>>; | ||
// @ts-ignore | ||
type __VLS_Element = __VLS_PickNotAny<import('vue/jsx-runtime').JSX.Element, JSX.Element>; | ||
// @ts-ignore | ||
type __VLS_GlobalComponents = ${[ | ||
`__VLS_PickNotAny<import('vue').GlobalComponents, {}>`, | ||
`__VLS_PickNotAny<import('@vue/runtime-core').GlobalComponents, {}>`, | ||
`__VLS_PickNotAny<import('@vue/runtime-dom').GlobalComponents, {}>`, | ||
`Pick<typeof import('${vueCompilerOptions.lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>` | ||
].join(' & ')}; | ||
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false; | ||
type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A; | ||
const __VLS_intrinsicElements: __VLS_IntrinsicElements; | ||
// v-for | ||
function __VLS_getVForSourceType(source: number): [number, number, number][]; | ||
function __VLS_getVForSourceType(source: string): [string, number, number][]; | ||
function __VLS_getVForSourceType<T extends any[]>(source: T): [ | ||
item: T[number], | ||
key: number, | ||
index: number, | ||
][]; | ||
function __VLS_getVForSourceType<T extends { [Symbol.iterator](): Iterator<any> }>(source: T): [ | ||
item: T extends { [Symbol.iterator](): Iterator<infer T1> } ? T1 : never, | ||
key: number, | ||
index: undefined, | ||
][]; | ||
// #3845 | ||
function __VLS_getVForSourceType<T extends number | { [Symbol.iterator](): Iterator<any> }>(source: T): [ | ||
item: number | (Exclude<T, number> extends { [Symbol.iterator](): Iterator<infer T1> } ? T1 : never), | ||
key: number, | ||
index: undefined, | ||
][]; | ||
function __VLS_getVForSourceType<T>(source: T): [ | ||
item: T[keyof T], | ||
key: keyof T, | ||
index: number, | ||
][]; | ||
// @ts-ignore | ||
function __VLS_getSlotParams<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>; | ||
// @ts-ignore | ||
function __VLS_getSlotParam<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>[0]; | ||
function __VLS_directiveFunction<T>(dir: T): | ||
T extends import('${vueCompilerOptions.lib}').ObjectDirective<infer E, infer V> | import('${vueCompilerOptions.lib}').FunctionDirective<infer E, infer V> ? (value: V) => void | ||
: T; | ||
function __VLS_withScope<T, K>(ctx: T, scope: K): ctx is T & K; | ||
function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] }; | ||
type __VLS_SelfComponent<N, C> = string extends N ? {} : N extends string ? { [P in N]: C } : {}; | ||
type __VLS_WithComponent<N0 extends string, LocalComponents, N1 extends string, N2 extends string, N3 extends string> = | ||
N1 extends keyof LocalComponents ? N1 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : { [K in N0]: LocalComponents[N1] } : | ||
N2 extends keyof LocalComponents ? N2 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : { [K in N0]: LocalComponents[N2] } : | ||
N3 extends keyof LocalComponents ? N3 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : { [K in N0]: LocalComponents[N3] } : | ||
N1 extends keyof __VLS_GlobalComponents ? N1 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N1] } : | ||
N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N2] } : | ||
N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N3] } : | ||
${vueCompilerOptions.strictTemplates ? '{}' : '{ [K in N0]: unknown }'} | ||
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): | ||
T extends new (...args: any) => any | ||
? (props: ${fnPropsType}, ctx?: any) => __VLS_Element & { __ctx?: { | ||
attrs?: any, | ||
slots?: K extends { ${(0, shared_1.getSlotsPropertyName)(vueCompilerOptions.target)}: infer Slots } ? Slots : any, | ||
emit?: K extends { $emit: infer Emit } ? Emit : any | ||
} & { props?: ${fnPropsType}; expose?(exposed: K): void; } } | ||
: T extends () => any ? (props: {}, ctx?: any) => ReturnType<T> | ||
: T extends (...args: any) => any ? T | ||
: (_: {}${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}, ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: {}${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'} } }; | ||
function __VLS_elementAsFunctionalComponent<T>(t: T): (_: T${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}, ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: T${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'} } }; | ||
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< | ||
'__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: infer Ctx } ? Ctx : never : any | ||
, T extends (props: any, ctx: infer Ctx) => any ? Ctx : any | ||
>; | ||
type __VLS_FunctionalComponentProps<T, K> = | ||
'__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never | ||
: T extends (props: infer P, ...args: any) => any ? P : | ||
{}; | ||
type __VLS_AsFunctionOrAny<F> = unknown extends F ? any : ((...args: any) => any) extends F ? F : any; | ||
function __VLS_normalizeSlot<S>(s: S): S extends () => infer R ? (props: {}) => R : S; | ||
/** | ||
* emit | ||
*/ | ||
// fix https://github.com/vuejs/language-tools/issues/926 | ||
type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never; | ||
type __VLS_OverloadUnionInner<T, U = unknown> = U & T extends (...args: infer A) => infer R | ||
? U extends T | ||
? never | ||
: __VLS_OverloadUnionInner<T, Pick<T, keyof T> & U & ((...args: A) => R)> | ((...args: A) => R) | ||
: never; | ||
type __VLS_OverloadUnion<T> = Exclude< | ||
__VLS_OverloadUnionInner<(() => never) & T>, | ||
T extends () => never ? never : () => never | ||
>; | ||
type __VLS_ConstructorOverloads<T> = __VLS_OverloadUnion<T> extends infer F | ||
? F extends (event: infer E, ...args: infer A) => any | ||
? { [K in E & string]: (...args: A) => void; } | ||
: never | ||
: never; | ||
type __VLS_NormalizeEmits<T> = __VLS_PrettifyGlobal< | ||
__VLS_UnionToIntersection< | ||
__VLS_ConstructorOverloads<T> & { | ||
[K in keyof T]: T[K] extends any[] ? { (...args: T[K]): void } : never | ||
} | ||
> | ||
>; | ||
type __VLS_PrettifyGlobal<T> = { [K in keyof T]: T[K]; } & {}; | ||
} | ||
`); | ||
} | ||
function* generateLocalHelperTypes() { | ||
@@ -706,2 +591,14 @@ let shouldCheck = true; | ||
} | ||
if (defineProp.modifierType) { | ||
let propModifierName = 'modelModifiers'; | ||
if (defineProp.name) { | ||
propModifierName = `${scriptSetup.content.substring(defineProp.name.start + 1, defineProp.name.end - 1)}Modifiers`; | ||
} | ||
const modifierType = scriptSetup.content.substring(defineProp.modifierType.start, defineProp.modifierType.end); | ||
const start = getGeneratedLength(); | ||
definePropMirrors.set(propModifierName, start); | ||
yield _(propModifierName); | ||
yield _(`: `); | ||
yield _(`import('${vueCompilerOptions.lib}').PropType<Record<${modifierType}, true>>,\n`); | ||
} | ||
} | ||
@@ -708,0 +605,0 @@ yield _(`};\n`); |
import * as CompilerDOM from '@vue/compiler-dom'; | ||
import type * as ts from 'typescript'; | ||
import type { Code, Sfc, VueCompilerOptions } from '../types'; | ||
export declare function generate(ts: typeof import('typescript'), compilerOptions: ts.CompilerOptions, vueCompilerOptions: VueCompilerOptions, template: NonNullable<Sfc['template']>, shouldGenerateScopedClasses: boolean, stylesScopedClasses: Set<string>, hasScriptSetupSlots: boolean, slotsAssignName: string | undefined, propsAssignName: string | undefined, codegenStack: boolean): Generator<[codeType: "ts" | "tsFormat" | "inlineCss", code: Code, stack: string], { | ||
import type { CodeAndStack, Sfc, VueCompilerOptions } from '../types'; | ||
export declare function generate(ts: typeof import('typescript'), compilerOptions: ts.CompilerOptions, vueCompilerOptions: VueCompilerOptions, template: NonNullable<Sfc['template']>, shouldGenerateScopedClasses: boolean, stylesScopedClasses: Set<string>, hasScriptSetupSlots: boolean, slotsAssignName: string | undefined, propsAssignName: string | undefined, codegenStack: boolean): Generator<CodeAndStack, { | ||
tagOffsetsMap: Map<string, number[]>; | ||
@@ -9,2 +9,12 @@ accessedGlobalVariables: Set<string>; | ||
}, unknown>; | ||
export declare function eachElementNode(node: CompilerDOM.RootNode | CompilerDOM.TemplateChildNode): Generator<CompilerDOM.ElementNode>; | ||
export declare function createTsAst(ts: typeof import('typescript'), astHolder: any, text: string): ts.SourceFile; | ||
export declare function isCompoundExpression(ts: typeof import('typescript'), ast: ts.SourceFile): boolean; | ||
export declare function parseInterpolationNode(node: CompilerDOM.InterpolationNode, template: string): readonly [string, number]; | ||
export declare function parseVForNode(node: CompilerDOM.ForNode): { | ||
leftExpressionRange: { | ||
start: number; | ||
end: number; | ||
} | undefined; | ||
leftExpressionText: string | undefined; | ||
}; | ||
export declare function forEachElementNode(node: CompilerDOM.RootNode | CompilerDOM.TemplateChildNode): Generator<CompilerDOM.ElementNode>; |
@@ -1,3 +0,2 @@ | ||
import type { Code, CodeAndStack, VueCodeInformation } from '../types'; | ||
export declare function withStack(code: Code): CodeAndStack; | ||
import type { VueCodeInformation } from '../types'; | ||
export declare function getStack(): string; | ||
@@ -4,0 +3,0 @@ export declare function disableAllFeatures(override: Partial<VueCodeInformation>): VueCodeInformation; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.mergeFeatureSettings = exports.enableAllFeatures = exports.disableAllFeatures = exports.getStack = exports.withStack = void 0; | ||
function withStack(code) { | ||
return [code, getStack()]; | ||
} | ||
exports.withStack = withStack; | ||
exports.mergeFeatureSettings = exports.enableAllFeatures = exports.disableAllFeatures = exports.getStack = void 0; | ||
// TODO: import from muggle-string | ||
@@ -9,0 +5,0 @@ function getStack() { |
import { type LanguagePlugin } from '@volar/language-core'; | ||
import type * as ts from 'typescript'; | ||
import type { VueCompilerOptions } from './types'; | ||
import type { VueCompilerOptions, VueLanguagePlugin } from './types'; | ||
import { VueGeneratedCode } from './virtualFile/vueFile'; | ||
export declare function createVueLanguagePlugin(ts: typeof import('typescript'), getFileName: (fileId: string) => string, isValidGlobalTypesHolder: (fileName: string) => boolean, compilerOptions: ts.CompilerOptions, vueCompilerOptions: VueCompilerOptions, codegenStack?: boolean): LanguagePlugin<VueGeneratedCode>; | ||
interface _Plugin extends LanguagePlugin<VueGeneratedCode> { | ||
getCanonicalFileName: (fileName: string) => string; | ||
pluginContext: Parameters<VueLanguagePlugin>[0]; | ||
} | ||
export declare function createVueLanguagePlugin(ts: typeof import('typescript'), getFileName: (fileId: string) => string, useCaseSensitiveFileNames: boolean, getProjectVersion: () => string, getScriptFileNames: () => string[] | Set<string>, compilerOptions: ts.CompilerOptions, vueCompilerOptions: VueCompilerOptions, codegenStack?: boolean): _Plugin; | ||
export {}; |
@@ -38,3 +38,3 @@ "use strict"; | ||
} | ||
function createVueLanguagePlugin(ts, getFileName, isValidGlobalTypesHolder, compilerOptions, vueCompilerOptions, codegenStack = false) { | ||
function createVueLanguagePlugin(ts, getFileName, useCaseSensitiveFileNames, getProjectVersion, getScriptFileNames, compilerOptions, vueCompilerOptions, codegenStack = false) { | ||
const allowLanguageIds = new Set(['vue']); | ||
@@ -63,7 +63,19 @@ const pluginContext = { | ||
} | ||
const getCanonicalFileName = useCaseSensitiveFileNames | ||
? (fileName) => fileName | ||
: (fileName) => fileName.toLowerCase(); | ||
let canonicalRootFileNames = new Set(); | ||
let canonicalRootFileNamesVersion; | ||
return { | ||
getCanonicalFileName, | ||
pluginContext, | ||
createVirtualCode(fileId, languageId, snapshot) { | ||
if (allowLanguageIds.has(languageId)) { | ||
const fileName = getFileName(fileId); | ||
if (!pluginContext.globalTypesHolder && isValidGlobalTypesHolder(fileName)) { | ||
const projectVersion = getProjectVersion(); | ||
if (projectVersion !== canonicalRootFileNamesVersion) { | ||
canonicalRootFileNames = new Set([...getScriptFileNames()].map(getCanonicalFileName)); | ||
canonicalRootFileNamesVersion = projectVersion; | ||
} | ||
if (!pluginContext.globalTypesHolder && canonicalRootFileNames.has(getCanonicalFileName(fileName))) { | ||
pluginContext.globalTypesHolder = fileName; | ||
@@ -88,21 +100,26 @@ } | ||
}, | ||
disposeVirtualCode(fileId, code, files) { | ||
const isGlobalTypesHolder = code.fileName === pluginContext.globalTypesHolder; | ||
const fileRegistry = getFileRegistry(isGlobalTypesHolder); | ||
fileRegistry.delete(fileId); | ||
if (isGlobalTypesHolder) { | ||
pluginContext.globalTypesHolder = undefined; | ||
const fileRegistry2 = getFileRegistry(false); | ||
for (const [fileId, code] of fileRegistry2) { | ||
if (isValidGlobalTypesHolder(code.fileName)) { | ||
pluginContext.globalTypesHolder = code.fileName; | ||
fileRegistry2.delete(fileId); | ||
// force dirty | ||
files?.delete(fileId); | ||
files?.set(fileId, code.languageId, code.snapshot); | ||
break; | ||
} | ||
} | ||
} | ||
}, | ||
// TODO: when global types holder deleted, move global types to another file | ||
// disposeVirtualCode(fileId, code) { | ||
// const isGlobalTypesHolder = code.fileName === pluginContext.globalTypesHolder; | ||
// const fileRegistry = getFileRegistry(isGlobalTypesHolder); | ||
// fileRegistry.delete(fileId); | ||
// if (isGlobalTypesHolder) { | ||
// pluginContext.globalTypesHolder = undefined; | ||
// const fileRegistry2 = getFileRegistry(false); | ||
// for (const [fileId, code] of fileRegistry2) { | ||
// if (isValidGlobalTypesHolder(code.fileName)) { | ||
// pluginContext.globalTypesHolder = code.fileName; | ||
// fileRegistry2.delete(fileId); | ||
// // force dirty | ||
// files?.delete(fileId); | ||
// files?.set( | ||
// fileId, | ||
// code.languageId, | ||
// code.snapshot, | ||
// ); | ||
// break; | ||
// } | ||
// } | ||
// } | ||
// }, | ||
typescript: { | ||
@@ -114,4 +131,4 @@ extraFileExtensions: vueCompilerOptions.extensions.map(ext => ({ | ||
})), | ||
getScript(rootVirtualCode) { | ||
for (const code of (0, language_core_1.forEachEmbeddedCode)(rootVirtualCode)) { | ||
getServiceScript(root) { | ||
for (const code of (0, language_core_1.forEachEmbeddedCode)(root)) { | ||
if (code.id.startsWith('script_')) { | ||
@@ -118,0 +135,0 @@ const lang = code.id.substring('script_'.length); |
@@ -46,2 +46,3 @@ import type * as ts from 'typescript'; | ||
type: TextRange | undefined; | ||
modifierType?: TextRange | undefined; | ||
defaultValue: TextRange | undefined; | ||
@@ -48,0 +49,0 @@ required: boolean; |
@@ -90,2 +90,3 @@ "use strict"; | ||
type: node.typeArguments?.length ? _getStartEnd(node.typeArguments[0]) : undefined, | ||
modifierType: node.typeArguments && node.typeArguments?.length >= 2 ? _getStartEnd(node.typeArguments[1]) : undefined, | ||
defaultValue: undefined, | ||
@@ -92,0 +93,0 @@ required, |
@@ -12,2 +12,4 @@ "use strict"; | ||
const vue_template_html_1 = require("./plugins/vue-template-html"); | ||
const vue_template_inline_css_1 = require("./plugins/vue-template-inline-css"); | ||
const vue_template_inline_ts_1 = require("./plugins/vue-template-inline-ts"); | ||
const vue_tsx_1 = require("./plugins/vue-tsx"); | ||
@@ -21,2 +23,4 @@ const types_1 = require("./types"); | ||
vue_template_html_1.default, | ||
vue_template_inline_css_1.default, | ||
vue_template_inline_ts_1.default, | ||
vue_sfc_styles_1.default, | ||
@@ -23,0 +27,0 @@ vue_sfc_customblocks_1.default, |
@@ -8,17 +8,43 @@ "use strict"; | ||
getEmbeddedCodes(_fileName, sfc) { | ||
return sfc.styles.map((style, i) => ({ | ||
id: 'style_' + i, | ||
lang: style.lang, | ||
})); | ||
const result = []; | ||
for (let i = 0; i < sfc.styles.length; i++) { | ||
const style = sfc.styles[i]; | ||
if (style) { | ||
result.push({ | ||
id: 'style_' + i, | ||
lang: style.lang, | ||
}); | ||
if (style.cssVars.length) { | ||
result.push({ | ||
id: 'style_' + i + '_inline_ts', | ||
lang: 'ts', | ||
}); | ||
} | ||
} | ||
} | ||
return result; | ||
}, | ||
resolveEmbeddedCode(_fileName, sfc, embeddedFile) { | ||
if (embeddedFile.id.startsWith('style_')) { | ||
const index = parseInt(embeddedFile.id.slice('style_'.length)); | ||
const index = parseInt(embeddedFile.id.split('_')[1]); | ||
const style = sfc.styles[index]; | ||
embeddedFile.content.push([ | ||
style.content, | ||
style.name, | ||
0, | ||
(0, utils_1.enableAllFeatures)({}), | ||
]); | ||
if (embeddedFile.id.endsWith('_inline_ts')) { | ||
embeddedFile.parentCodeId = 'style_' + index; | ||
for (const cssVar of style.cssVars) { | ||
embeddedFile.content.push('(', [ | ||
cssVar.text, | ||
style.name, | ||
cssVar.offset, | ||
(0, utils_1.enableAllFeatures)({}), | ||
], ');\n'); | ||
} | ||
} | ||
else { | ||
embeddedFile.content.push([ | ||
style.content, | ||
style.name, | ||
0, | ||
(0, utils_1.enableAllFeatures)({}), | ||
]); | ||
} | ||
} | ||
@@ -25,0 +51,0 @@ }, |
@@ -56,2 +56,3 @@ import { Mapping, StackNode } from '@volar/language-core'; | ||
type: import("../types").TextRange | undefined; | ||
modifierType?: import("../types").TextRange | undefined; | ||
defaultValue: import("../types").TextRange | undefined; | ||
@@ -71,6 +72,2 @@ required: boolean; | ||
codeStacks: string[]; | ||
formatCodes: Code[]; | ||
formatCodeStacks: string[]; | ||
cssCodes: Code[]; | ||
cssCodeStacks: string[]; | ||
tagOffsetsMap: Map<string, number[]>; | ||
@@ -77,0 +74,0 @@ accessedGlobalVariables: Set<string>; |
@@ -8,3 +8,2 @@ "use strict"; | ||
const template_1 = require("../generators/template"); | ||
const utils_1 = require("../generators/utils"); | ||
const scriptRanges_1 = require("../parsers/scriptRanges"); | ||
@@ -26,6 +25,2 @@ const scriptSetupRanges_1 = require("../parsers/scriptSetupRanges"); | ||
} | ||
if (sfc.template) { | ||
files.push({ id: 'template_format', lang: 'ts' }); | ||
files.push({ id: 'template_style', lang: 'css' }); | ||
} | ||
return files; | ||
@@ -39,8 +34,2 @@ }, | ||
const [content, contentStacks] = ctx.codegenStack ? (0, language_core_1.track)([...tsx.codes], [...tsx.codeStacks]) : [[...tsx.codes], [...tsx.codeStacks]]; | ||
content.forEach(code => { | ||
if (typeof code !== 'string') { | ||
code[3].structure = false; | ||
code[3].format = false; | ||
} | ||
}); | ||
embeddedFile.content = content; | ||
@@ -51,37 +40,2 @@ embeddedFile.contentStacks = contentStacks; | ||
} | ||
else if (embeddedFile.id === 'template_format') { | ||
embeddedFile.parentCodeId = 'template'; | ||
const template = _tsx.generatedTemplate(); | ||
if (template) { | ||
const [content, contentStacks] = ctx.codegenStack | ||
? (0, language_core_1.track)([...template.formatCodes], template.formatCodeStacks.map(stack => ({ stack, length: 1 }))) | ||
: [[...template.formatCodes], template.formatCodeStacks.map(stack => ({ stack, length: 1 }))]; | ||
embeddedFile.content = content; | ||
embeddedFile.contentStacks = contentStacks; | ||
} | ||
for (const style of sfc.styles) { | ||
embeddedFile.content.push('\n\n'); | ||
for (const cssVar of style.cssVars) { | ||
embeddedFile.content.push('('); | ||
embeddedFile.content.push([ | ||
cssVar.text, | ||
style.name, | ||
cssVar.offset, | ||
(0, utils_1.enableAllFeatures)({}), | ||
]); | ||
embeddedFile.content.push(');\n'); | ||
} | ||
} | ||
} | ||
else if (embeddedFile.id === 'template_style') { | ||
embeddedFile.parentCodeId = 'template'; | ||
const template = _tsx.generatedTemplate(); | ||
if (template) { | ||
const [content, contentStacks] = ctx.codegenStack | ||
? (0, language_core_1.track)([...template.cssCodes], template.cssCodeStacks.map(stack => ({ stack, length: 1 }))) | ||
: [[...template.cssCodes], template.cssCodeStacks.map(stack => ({ stack, length: 1 }))]; | ||
embeddedFile.content = content; | ||
embeddedFile.contentStacks = contentStacks; | ||
} | ||
} | ||
}, | ||
@@ -137,30 +91,10 @@ }; | ||
const tsCodes = []; | ||
const tsFormatCodes = []; | ||
const inlineCssCodes = []; | ||
const tsCodegenStacks = []; | ||
const tsFormatCodegenStacks = []; | ||
const inlineCssCodegenStacks = []; | ||
const codegen = (0, template_1.generate)(ts, ctx.compilerOptions, ctx.vueCompilerOptions, _sfc.template, shouldGenerateScopedClasses(), stylesScopedClasses(), hasScriptSetupSlots(), slotsAssignName(), propsAssignName(), ctx.codegenStack); | ||
let current = codegen.next(); | ||
while (!current.done) { | ||
const [type, code, stack] = current.value; | ||
if (type === 'ts') { | ||
tsCodes.push(code); | ||
} | ||
else if (type === 'tsFormat') { | ||
tsFormatCodes.push(code); | ||
} | ||
else if (type === 'inlineCss') { | ||
inlineCssCodes.push(code); | ||
} | ||
const [code, stack] = current.value; | ||
tsCodes.push(code); | ||
if (ctx.codegenStack) { | ||
if (type === 'ts') { | ||
tsCodegenStacks.push(stack); | ||
} | ||
else if (type === 'tsFormat') { | ||
tsFormatCodegenStacks.push(stack); | ||
} | ||
else if (type === 'inlineCss') { | ||
inlineCssCodegenStacks.push(stack); | ||
} | ||
tsCodegenStacks.push(stack); | ||
} | ||
@@ -173,6 +107,2 @@ current = codegen.next(); | ||
codeStacks: tsCodegenStacks, | ||
formatCodes: tsFormatCodes, | ||
formatCodeStacks: tsFormatCodegenStacks, | ||
cssCodes: inlineCssCodes, | ||
cssCodeStacks: inlineCssCodegenStacks, | ||
}; | ||
@@ -179,0 +109,0 @@ }); |
@@ -39,12 +39,3 @@ "use strict"; | ||
} | ||
for (const { file, snapshot, mappings, codegenStacks } of remain) { | ||
embeddedCodes.push({ | ||
id: file.id, | ||
languageId: (0, language_core_1.resolveCommonLanguageId)(`/dummy.${file.lang}`), | ||
linkedCodeMappings: file.linkedCodeMappings, | ||
snapshot, | ||
mappings, | ||
codegenStacks, | ||
embeddedCodes: [], | ||
}); | ||
for (const { file } of remain) { | ||
console.error('Unable to resolve embedded: ' + file.parentCodeId + ' -> ' + file.id); | ||
@@ -51,0 +42,0 @@ } |
{ | ||
"name": "@vue/language-core", | ||
"version": "2.0.7", | ||
"version": "2.0.10", | ||
"license": "MIT", | ||
@@ -15,3 +15,3 @@ "files": [ | ||
"dependencies": { | ||
"@volar/language-core": "~2.1.3", | ||
"@volar/language-core": "~2.2.0-alpha.5", | ||
"@vue/compiler-dom": "^3.4.0", | ||
@@ -38,3 +38,3 @@ "@vue/shared": "^3.4.0", | ||
}, | ||
"gitHead": "4a37e8f3ebcf31ecfd2ea627f7611d5990ec5df6" | ||
"gitHead": "a20a2ee950b63a949660b7e8faf0faed0e5bad33" | ||
} |
Sorry, the diff of this file is too big to display
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
266651
72
5934
+ Added@volar/language-core@2.2.5(transitive)
+ Added@volar/source-map@2.2.5(transitive)
- Removed@volar/language-core@2.1.6(transitive)
- Removed@volar/source-map@2.1.6(transitive)