@volar/vue-language-core
Advanced tools
Comparing version 1.0.9 to 1.0.10
@@ -254,3 +254,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
// use defineComponent() from user space code if it exist | ||
codeGen.push(`const __VLS_Component = `); | ||
codeGen.push(`const __VLS_publicComponent = `); | ||
addVirtualCode('script', scriptRanges.exportDefault.expression.start, scriptRanges.exportDefault.args.start); | ||
@@ -260,3 +260,3 @@ codeGen.push(`{\n`); | ||
else { | ||
codeGen.push(`const __VLS_Component = (await import('${vueLibName}')).defineComponent({\n`); | ||
codeGen.push(`const __VLS_publicComponent = (await import('${vueLibName}')).defineComponent({\n`); | ||
} | ||
@@ -352,3 +352,3 @@ if (!bypassDefineComponent) { | ||
if (vueCompilerOptions.experimentalRfc436) { | ||
codeGen.push(`return {} as Omit<JSX.Element, 'props' | 'children'> & Omit<InstanceType<typeof __VLS_Component>, '$slots' | '$emit'>`); | ||
codeGen.push(`return {} as Omit<JSX.Element, 'props' | 'children'> & Omit<InstanceType<typeof __VLS_publicComponent>, '$slots' | '$emit'>`); | ||
codeGen.push(` & {\n`); | ||
@@ -359,3 +359,3 @@ if (scriptSetupRanges.propsTypeArg) { | ||
else { | ||
codeGen.push(`props: InstanceType<typeof __VLS_Component>['$props'],\n`); | ||
codeGen.push(`props: InstanceType<typeof __VLS_publicComponent>['$props'],\n`); | ||
} | ||
@@ -367,3 +367,3 @@ codeGen.push(`$emit: `); | ||
else { | ||
codeGen.push(`InstanceType<typeof __VLS_Component>['$emit']`); | ||
codeGen.push(`InstanceType<typeof __VLS_publicComponent>['$emit']`); | ||
} | ||
@@ -380,3 +380,3 @@ codeGen.push(`,\n`); | ||
else { | ||
codeGen.push(`return {} as typeof __VLS_Component`); | ||
codeGen.push(`return {} as typeof __VLS_publicComponent`); | ||
if (htmlGen === null || htmlGen === void 0 ? void 0 : htmlGen.slotsNum) { | ||
@@ -427,3 +427,3 @@ codeGen.push(` & { new (): { $slots: ReturnType<typeof __VLS_template> } }`); | ||
if (sfc.scriptSetup && scriptSetupRanges) { | ||
codeGen.push(`const __VLS_component = (await import('${vueLibName}')).defineComponent({\n`); | ||
codeGen.push(`const __VLS_internalComponent = (await import('${vueLibName}')).defineComponent({\n`); | ||
codeGen.push(`setup() {\n`); | ||
@@ -501,6 +501,6 @@ codeGen.push(`return {\n`); | ||
else if (sfc.script) { | ||
codeGen.push(`let __VLS_component!: typeof import('./${path_1.posix.basename(fileName)}')['default'];\n`); | ||
codeGen.push(`let __VLS_internalComponent!: typeof import('./${path_1.posix.basename(fileName)}')['default'];\n`); | ||
} | ||
else { | ||
codeGen.push(`const __VLS_component = (await import('${vueLibName}')).defineComponent({});\n`); | ||
codeGen.push(`const __VLS_internalComponent = (await import('${vueLibName}')).defineComponent({});\n`); | ||
} | ||
@@ -551,5 +551,5 @@ } | ||
if (sfc.scriptSetup) { | ||
codeGen.push(`InstanceType<import('./__VLS_types.js').PickNotAny<typeof __VLS_Component, new () => {}>> & `); | ||
codeGen.push(`InstanceType<import('./__VLS_types.js').PickNotAny<typeof __VLS_publicComponent, new () => {}>> & `); | ||
} | ||
codeGen.push(`InstanceType<import('./__VLS_types.js').PickNotAny<typeof __VLS_component, new () => {}>> & {\n`); | ||
codeGen.push(`InstanceType<import('./__VLS_types.js').PickNotAny<typeof __VLS_internalComponent, new () => {}>> & {\n`); | ||
/* CSS Module */ | ||
@@ -566,5 +566,6 @@ for (const cssModule of cssModuleClasses) { | ||
codeGen.push('/* Components */\n'); | ||
codeGen.push(`let __VLS_otherComponents!: NonNullable<typeof __VLS_component extends { components: infer C } ? C : {}> & import('./__VLS_types.js').GlobalComponents & typeof __VLS_componentsOption & typeof __VLS_ctx;\n`); | ||
codeGen.push(`let __VLS_selfComponent!: import('./__VLS_types.js').SelfComponent<typeof __VLS_name, typeof __VLS_component & (new () => { ${(0, shared_2.getSlotsPropertyName)((_a = vueCompilerOptions.target) !== null && _a !== void 0 ? _a : 3)}: typeof __VLS_slots })>;\n`); | ||
codeGen.push(`let __VLS_components!: typeof __VLS_otherComponents & Omit<typeof __VLS_selfComponent, keyof typeof __VLS_otherComponents>;\n`); | ||
codeGen.push(`let __VLS_localComponents!: NonNullable<typeof __VLS_internalComponent extends { components: infer C } ? C : {}> & typeof __VLS_componentsOption & typeof __VLS_ctx;\n`); | ||
codeGen.push(`let __VLS_otherComponents!: typeof __VLS_localComponents & Omit<import('./__VLS_types.js').GlobalComponents, keyof typeof __VLS_localComponents>;\n`); | ||
codeGen.push(`let __VLS_own!: import('./__VLS_types.js').SelfComponent<typeof __VLS_name, typeof __VLS_internalComponent & typeof __VLS_publicComponent & (new () => { ${(0, shared_2.getSlotsPropertyName)((_a = vueCompilerOptions.target) !== null && _a !== void 0 ? _a : 3)}: typeof __VLS_slots })>;\n`); | ||
codeGen.push(`let __VLS_components!: typeof __VLS_otherComponents & Omit<typeof __VLS_own, keyof typeof __VLS_otherComponents>;\n`); | ||
/* Style Scoped */ | ||
@@ -571,0 +572,0 @@ codeGen.push('/* Style Scoped */\n'); |
import { PositionCapabilities } from '@volar/language-core'; | ||
import * as CompilerDOM from '@vue/compiler-dom'; | ||
import { ResolvedVueCompilerOptions } from '../types'; | ||
export declare function isIntrinsicElement(runtimeMode: 'runtime-dom' | 'runtime-uni-app', tag: string): boolean; | ||
export declare function generate(ts: typeof import('typescript/lib/tsserverlibrary'), vueCompilerOptions: ResolvedVueCompilerOptions, sourceTemplate: string, sourceLang: string, templateAst: CompilerDOM.RootNode, hasScriptSetup: boolean, cssScopedClasses?: string[]): { | ||
@@ -6,0 +5,0 @@ codeGen: import("@volar/source-map").SegmentWithData<PositionCapabilities>[]; |
import type * as embedded from '@volar/language-core'; | ||
import { VueLanguagePlugin, VueCompilerOptions } from './types'; | ||
import type * as ts from 'typescript/lib/tsserverlibrary'; | ||
export declare function createLanguageModule(ts: typeof import('typescript/lib/tsserverlibrary'), rootDir: string, compilerOptions: ts.CompilerOptions, _vueCompilerOptions: VueCompilerOptions, extraPlugins?: VueLanguagePlugin[]): embedded.LanguageModule; |
@@ -28,3 +28,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
&& !ts.isImportEqualsDeclaration(node)) { | ||
importSectionEndOffset = node.getStart(ast); | ||
importSectionEndOffset = node.getStart(ast, true); | ||
foundNonImportExportNode = true; | ||
@@ -31,0 +31,0 @@ } |
@@ -126,2 +126,5 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
} | ||
else { | ||
VueSourceFile.compiledSFCTemplateCache = undefined; | ||
} | ||
return { | ||
@@ -128,0 +131,0 @@ errors, |
@@ -17,2 +17,3 @@ import * as embedded from '@volar/language-core'; | ||
skipTemplateCodegen: boolean; | ||
nativeTags: string[]; | ||
dataAttributes: string[]; | ||
@@ -24,3 +25,2 @@ htmlAttributes: string[]; | ||
bypassDefineComponentToExposePropsAndEmitsForJsScriptSetupComponents: boolean; | ||
experimentalRuntimeMode: 'runtime-dom' | 'runtime-uni-app'; | ||
experimentalResolveStyleCssClasses: 'scoped' | 'always' | 'never'; | ||
@@ -27,0 +27,0 @@ experimentalRfc436: boolean; |
@@ -124,3 +124,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
type GlobalAttrs = JSX.IntrinsicElements['div']; | ||
type IntrinsicElements = JSX.IntrinsicElements; | ||
`; | ||
@@ -127,0 +127,0 @@ } |
@@ -48,10 +48,38 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
} | ||
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element | ||
const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' + | ||
'header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' + | ||
'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' + | ||
'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' + | ||
'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' + | ||
'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' + | ||
'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' + | ||
'option,output,progress,select,textarea,details,dialog,menu,' + | ||
'summary,template,blockquote,iframe,tfoot'; | ||
// https://developer.mozilla.org/en-US/docs/Web/SVG/Element | ||
const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' + | ||
'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' + | ||
'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' + | ||
'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' + | ||
'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' + | ||
'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' + | ||
'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' + | ||
'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' + | ||
'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' + | ||
'text,textPath,title,tspan,unknown,use,view'; | ||
function resolveVueCompilerOptions(vueOptions) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; | ||
const target = (_a = vueOptions.target) !== null && _a !== void 0 ? _a : 3; | ||
return Object.assign(Object.assign({}, vueOptions), { target, extensions: (_b = vueOptions.extensions) !== null && _b !== void 0 ? _b : ['.vue'], jsxTemplates: (_c = vueOptions.jsxTemplates) !== null && _c !== void 0 ? _c : false, strictTemplates: (_d = vueOptions.strictTemplates) !== null && _d !== void 0 ? _d : false, skipTemplateCodegen: (_e = vueOptions.skipTemplateCodegen) !== null && _e !== void 0 ? _e : false, dataAttributes: (_f = vueOptions.dataAttributes) !== null && _f !== void 0 ? _f : [], htmlAttributes: (_g = vueOptions.htmlAttributes) !== null && _g !== void 0 ? _g : ['aria-*'], optionsWrapper: (_h = vueOptions.optionsWrapper) !== null && _h !== void 0 ? _h : (target >= 2.7 | ||
return Object.assign(Object.assign({}, vueOptions), { target, extensions: (_b = vueOptions.extensions) !== null && _b !== void 0 ? _b : ['.vue'], jsxTemplates: (_c = vueOptions.jsxTemplates) !== null && _c !== void 0 ? _c : false, strictTemplates: (_d = vueOptions.strictTemplates) !== null && _d !== void 0 ? _d : false, skipTemplateCodegen: (_e = vueOptions.skipTemplateCodegen) !== null && _e !== void 0 ? _e : false, nativeTags: (_f = vueOptions.nativeTags) !== null && _f !== void 0 ? _f : [...new Set([ | ||
...HTML_TAGS.split(','), | ||
...SVG_TAGS.split(','), | ||
// fix https://github.com/johnsoncodehk/volar/issues/1340 | ||
'hgroup', | ||
'slot', | ||
'component', | ||
])], dataAttributes: (_g = vueOptions.dataAttributes) !== null && _g !== void 0 ? _g : [], htmlAttributes: (_h = vueOptions.htmlAttributes) !== null && _h !== void 0 ? _h : ['aria-*'], optionsWrapper: (_j = vueOptions.optionsWrapper) !== null && _j !== void 0 ? _j : (target >= 2.7 | ||
? [`(await import('vue')).defineComponent(`, `)`] | ||
: [`(await import('vue')).default.extend(`, `)`]), narrowingTypesInInlineHandlers: (_j = vueOptions.narrowingTypesInInlineHandlers) !== null && _j !== void 0 ? _j : false, plugins: (_k = vueOptions.plugins) !== null && _k !== void 0 ? _k : [], bypassDefineComponentToExposePropsAndEmitsForJsScriptSetupComponents: (_l = vueOptions.bypassDefineComponentToExposePropsAndEmitsForJsScriptSetupComponents) !== null && _l !== void 0 ? _l : true, | ||
: [`(await import('vue')).default.extend(`, `)`]), narrowingTypesInInlineHandlers: (_k = vueOptions.narrowingTypesInInlineHandlers) !== null && _k !== void 0 ? _k : false, plugins: (_l = vueOptions.plugins) !== null && _l !== void 0 ? _l : [], bypassDefineComponentToExposePropsAndEmitsForJsScriptSetupComponents: (_m = vueOptions.bypassDefineComponentToExposePropsAndEmitsForJsScriptSetupComponents) !== null && _m !== void 0 ? _m : true, | ||
// experimental | ||
experimentalRuntimeMode: (_m = vueOptions.experimentalRuntimeMode) !== null && _m !== void 0 ? _m : 'runtime-dom', experimentalResolveStyleCssClasses: (_o = vueOptions.experimentalResolveStyleCssClasses) !== null && _o !== void 0 ? _o : 'scoped', experimentalRfc436: (_p = vueOptions.experimentalRfc436) !== null && _p !== void 0 ? _p : false, | ||
experimentalResolveStyleCssClasses: (_o = vueOptions.experimentalResolveStyleCssClasses) !== null && _o !== void 0 ? _o : 'scoped', experimentalRfc436: (_p = vueOptions.experimentalRfc436) !== null && _p !== void 0 ? _p : false, | ||
// https://github.com/vuejs/vue-next/blob/master/packages/compiler-dom/src/transforms/vModel.ts#L49-L51 | ||
@@ -58,0 +86,0 @@ // https://v3.vuejs.org/guide/forms.html#basic-usage |
@@ -76,6 +76,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (!prefixIdentifiers && options.cacheHandlers) { | ||
onError(CompilerDom.createCompilerError(48 /* CompilerDom.ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */)); | ||
onError(CompilerDom.createCompilerError(49 /* CompilerDom.ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */)); | ||
} | ||
if (options.scopeId && !isModuleMode) { | ||
onError(CompilerDom.createCompilerError(49 /* CompilerDom.ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */)); | ||
onError(CompilerDom.createCompilerError(50 /* CompilerDom.ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */)); | ||
} | ||
@@ -82,0 +82,0 @@ const ast = CompilerDom.baseParse(template, options); |
{ | ||
"name": "@volar/vue-language-core", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"main": "out/index.js", | ||
@@ -16,10 +16,10 @@ "license": "MIT", | ||
"dependencies": { | ||
"@volar/language-core": "1.0.9", | ||
"@volar/source-map": "1.0.9", | ||
"@vue/compiler-dom": "^3.2.40", | ||
"@vue/compiler-sfc": "^3.2.40", | ||
"@vue/reactivity": "^3.2.40", | ||
"@vue/shared": "^3.2.40", | ||
"@volar/language-core": "1.0.10", | ||
"@volar/source-map": "1.0.10", | ||
"@vue/compiler-dom": "^3.2.45", | ||
"@vue/compiler-sfc": "^3.2.45", | ||
"@vue/reactivity": "^3.2.45", | ||
"@vue/shared": "^3.2.45", | ||
"minimatch": "^5.1.0", | ||
"vue-template-compiler": "^2.7.10" | ||
"vue-template-compiler": "^2.7.14" | ||
}, | ||
@@ -29,3 +29,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "be2081f56ce4608324795b8a0ae83c288a3a784d" | ||
"gitHead": "89b82f92fdc30674b03941c5f17c60df8c46211c" | ||
} |
Sorry, the diff of this file is too big to display
233310
5054
+ Added@volar/language-core@1.0.10(transitive)
+ Added@volar/source-map@1.0.10(transitive)
- Removed@volar/language-core@1.0.9(transitive)
- Removed@volar/source-map@1.0.9(transitive)
Updated@volar/language-core@1.0.10
Updated@volar/source-map@1.0.10
Updated@vue/compiler-dom@^3.2.45
Updated@vue/compiler-sfc@^3.2.45
Updated@vue/reactivity@^3.2.45
Updated@vue/shared@^3.2.45