@volar/vue-language-core
Advanced tools
Comparing version 0.40.6 to 0.40.7
@@ -8,10 +8,9 @@ import { CodeGen } from '@volar/code-gen'; | ||
import { Sfc } from '../sourceFile'; | ||
import type { EmbeddedFileMappingData, TeleportMappingData } from '../types'; | ||
import { VueCompilerOptions } from '../types'; | ||
import type { EmbeddedFileMappingData, TeleportMappingData, _VueCompilerOptions } from '../types'; | ||
/** | ||
* TODO: rewrite this | ||
*/ | ||
export declare function generate(ts: typeof import('typescript/lib/tsserverlibrary'), fileName: string, sfc: Sfc, lang: string, scriptRanges: ScriptRanges | undefined, scriptSetupRanges: ScriptSetupRanges | undefined, cssVars: ReturnType<typeof collectCssVars>, cssModuleClasses: ReturnType<typeof collectStyleCssClasses>, cssScopedClasses: ReturnType<typeof collectStyleCssClasses>, htmlGen: ReturnType<typeof templateGen['generate']> | undefined, compilerOptions: ts.CompilerOptions, vueCompilerOptions: VueCompilerOptions, codeGen?: CodeGen<EmbeddedFileMappingData>, teleports?: SourceMaps.Mapping<TeleportMappingData>[]): { | ||
export declare function generate(ts: typeof import('typescript/lib/tsserverlibrary'), fileName: string, sfc: Sfc, lang: string, scriptRanges: ScriptRanges | undefined, scriptSetupRanges: ScriptSetupRanges | undefined, cssVars: ReturnType<typeof collectCssVars>, cssModuleClasses: ReturnType<typeof collectStyleCssClasses>, cssScopedClasses: ReturnType<typeof collectStyleCssClasses>, htmlGen: ReturnType<typeof templateGen['generate']> | undefined, compilerOptions: ts.CompilerOptions, vueCompilerOptions: _VueCompilerOptions, codeGen?: CodeGen<EmbeddedFileMappingData>, teleports?: SourceMaps.Mapping<TeleportMappingData>[]): { | ||
codeGen: CodeGen<EmbeddedFileMappingData>; | ||
teleports: SourceMaps.Mapping<TeleportMappingData>[]; | ||
}; |
@@ -164,13 +164,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
} | ||
const wrapMode = getImplicitWrapComponentOptionsMode(lang); | ||
if (isExportRawObject && wrapMode && (scriptRanges === null || scriptRanges === void 0 ? void 0 : scriptRanges.exportDefault)) { | ||
const warpperEnabled = vueCompilerOptions.experimentalComponentOptionsWrapperEnable === true | ||
|| (vueCompilerOptions.experimentalComponentOptionsWrapperEnable === 'onlyJs' && (lang === 'js' || lang === 'jsx')); | ||
if (isExportRawObject && warpperEnabled && (scriptRanges === null || scriptRanges === void 0 ? void 0 : scriptRanges.exportDefault)) { | ||
addVirtualCode('script', 0, scriptRanges.exportDefault.expression.start); | ||
if (wrapMode === 'defineComponent') { | ||
codeGen.addText(`(await import('${vueLibName}')).defineComponent(`); | ||
} | ||
else { | ||
codeGen.addText(`(await import('vue')).default.extend(`); | ||
} | ||
codeGen.addText(vueCompilerOptions.experimentalComponentOptionsWrapper[0]); | ||
addVirtualCode('script', scriptRanges.exportDefault.expression.start, scriptRanges.exportDefault.expression.end); | ||
codeGen.addText(`)`); | ||
codeGen.addText(vueCompilerOptions.experimentalComponentOptionsWrapper[1]); | ||
addVirtualCode('script', scriptRanges.exportDefault.expression.end, sfc.script.content.length); | ||
@@ -646,23 +642,2 @@ } | ||
} | ||
function getImplicitWrapComponentOptionsMode(lang) { | ||
let shimComponentOptionsMode = false; | ||
if (vueCompilerOptions.experimentalImplicitWrapComponentOptionsWithVue2Extend === 'onlyJs' | ||
? lang === 'js' || lang === 'jsx' | ||
: !!vueCompilerOptions.experimentalImplicitWrapComponentOptionsWithVue2Extend) { | ||
shimComponentOptionsMode = 'Vue.extend'; | ||
} | ||
if (vueCompilerOptions.experimentalImplicitWrapComponentOptionsWithDefineComponent === 'onlyJs' | ||
? lang === 'js' || lang === 'jsx' | ||
: !!vueCompilerOptions.experimentalImplicitWrapComponentOptionsWithDefineComponent) { | ||
shimComponentOptionsMode = 'defineComponent'; | ||
} | ||
// true override 'onlyJs' | ||
if (vueCompilerOptions.experimentalImplicitWrapComponentOptionsWithVue2Extend === true) { | ||
shimComponentOptionsMode = 'Vue.extend'; | ||
} | ||
if (vueCompilerOptions.experimentalImplicitWrapComponentOptionsWithDefineComponent === true) { | ||
shimComponentOptionsMode = 'defineComponent'; | ||
} | ||
return shimComponentOptionsMode; | ||
} | ||
} | ||
@@ -669,0 +644,0 @@ exports.generate = generate; |
@@ -6,3 +6,3 @@ import { CodeGen } from '@volar/code-gen'; | ||
export declare function isIntrinsicElement(runtimeMode: 'runtime-dom' | 'runtime-uni-app', tag: string): boolean; | ||
export declare function generate(ts: typeof import('typescript/lib/tsserverlibrary'), vueCompilerOptions: _VueCompilerOptions, sourceLang: string, templateAst: CompilerDOM.RootNode, hasScriptSetup: boolean, cssScopedClasses?: string[]): { | ||
export declare function generate(ts: typeof import('typescript/lib/tsserverlibrary'), vueCompilerOptions: _VueCompilerOptions, sourceTemplate: string, sourceLang: string, templateAst: CompilerDOM.RootNode, hasScriptSetup: boolean, cssScopedClasses?: string[]): { | ||
codeGen: CodeGen<EmbeddedFileMappingData>; | ||
@@ -9,0 +9,0 @@ formatCodeGen: CodeGen<EmbeddedFileMappingData>; |
@@ -138,2 +138,5 @@ const CompilerDOM = require("@vue/compiler-dom"); | ||
else if (node.type === 4 /* CompilerDOM.NodeTypes.SIMPLE_EXPRESSION */) { | ||
if (node.isStatic) { // slot name | ||
return false; | ||
} | ||
node.content = node.loc.source; | ||
@@ -140,0 +143,0 @@ } |
@@ -108,6 +108,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
const htmlGen = (0, reactivity_1.computed)(() => { | ||
var _a, _b; | ||
var _a, _b, _c, _d; | ||
if (!sfc.templateAst) | ||
return; | ||
return templateGen.generate(ts, vueCompilerOptions, (_b = (_a = sfc.template) === null || _a === void 0 ? void 0 : _a.lang) !== null && _b !== void 0 ? _b : 'html', sfc.templateAst, !!sfc.scriptSetup, Object.values(cssScopedClasses.value).map(style => style.classNames).flat()); | ||
return templateGen.generate(ts, vueCompilerOptions, (_b = (_a = sfc.template) === null || _a === void 0 ? void 0 : _a.content) !== null && _b !== void 0 ? _b : '', (_d = (_c = sfc.template) === null || _c === void 0 ? void 0 : _c.lang) !== null && _d !== void 0 ? _d : 'html', sfc.templateAst, !!sfc.scriptSetup, Object.values(cssScopedClasses.value).map(style => style.classNames).flat()); | ||
}); | ||
@@ -114,0 +114,0 @@ const tsxGen = (0, reactivity_1.computed)(() => (0, script_1.generate)(ts, fileName, sfc, lang.value, scriptRanges.value, scriptSetupRanges.value, cssVars.value, cssModuleClasses.value, cssScopedClasses.value, htmlGen.value, compilerOptions, vueCompilerOptions)); |
@@ -13,5 +13,5 @@ import type * as ts from 'typescript/lib/tsserverlibrary'; | ||
plugins: string[]; | ||
experimentalComponentOptionsWrapper: [string, string]; | ||
experimentalComponentOptionsWrapperEnable: boolean | 'onlyJs'; | ||
experimentalRuntimeMode: 'runtime-dom' | 'runtime-uni-app'; | ||
experimentalImplicitWrapComponentOptionsWithDefineComponent: boolean | 'onlyJs'; | ||
experimentalImplicitWrapComponentOptionsWithVue2Extend: boolean | 'onlyJs'; | ||
experimentalDowngradePropsAndEmitsToSetupReturnOnScriptSetup: boolean | 'onlyJs'; | ||
@@ -18,0 +18,0 @@ experimentalTemplateCompilerOptions: any; |
@@ -40,5 +40,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; | ||
return Object.assign(Object.assign({}, vueOptions), { target: (_a = vueOptions.target) !== null && _a !== void 0 ? _a : 3, strictTemplates: (_b = vueOptions.strictTemplates) !== null && _b !== void 0 ? _b : false, plugins: (_c = vueOptions.plugins) !== null && _c !== void 0 ? _c : [], | ||
const target = (_a = vueOptions.target) !== null && _a !== void 0 ? _a : 3; | ||
return Object.assign(Object.assign({}, vueOptions), { target, strictTemplates: (_b = vueOptions.strictTemplates) !== null && _b !== void 0 ? _b : false, plugins: (_c = vueOptions.plugins) !== null && _c !== void 0 ? _c : [], | ||
// experimental | ||
experimentalRuntimeMode: (_d = vueOptions.experimentalRuntimeMode) !== null && _d !== void 0 ? _d : 'runtime-dom', experimentalImplicitWrapComponentOptionsWithDefineComponent: (_e = vueOptions.experimentalImplicitWrapComponentOptionsWithDefineComponent) !== null && _e !== void 0 ? _e : 'onlyJs', experimentalImplicitWrapComponentOptionsWithVue2Extend: (_f = vueOptions.experimentalImplicitWrapComponentOptionsWithVue2Extend) !== null && _f !== void 0 ? _f : 'onlyJs', experimentalDowngradePropsAndEmitsToSetupReturnOnScriptSetup: (_g = vueOptions.experimentalDowngradePropsAndEmitsToSetupReturnOnScriptSetup) !== null && _g !== void 0 ? _g : 'onlyJs', experimentalTemplateCompilerOptions: (_h = vueOptions.experimentalTemplateCompilerOptions) !== null && _h !== void 0 ? _h : {}, experimentalTemplateCompilerOptionsRequirePath: (_j = vueOptions.experimentalTemplateCompilerOptionsRequirePath) !== null && _j !== void 0 ? _j : undefined, experimentalDisableTemplateSupport: (_k = vueOptions.experimentalDisableTemplateSupport) !== null && _k !== void 0 ? _k : false, experimentalResolveStyleCssClasses: (_l = vueOptions.experimentalResolveStyleCssClasses) !== null && _l !== void 0 ? _l : 'scoped', experimentalAllowTypeNarrowingInInlineHandlers: (_m = vueOptions.experimentalAllowTypeNarrowingInInlineHandlers) !== null && _m !== void 0 ? _m : false }); | ||
experimentalComponentOptionsWrapper: (_d = vueOptions.experimentalComponentOptionsWrapper) !== null && _d !== void 0 ? _d : (target >= 2.7 | ||
? [`(await import('vue')).defineComponent(`, `)`] | ||
: [`(await import('vue')).default.extend(`, `)`]), experimentalComponentOptionsWrapperEnable: (_e = vueOptions.experimentalComponentOptionsWrapperEnable) !== null && _e !== void 0 ? _e : 'onlyJs', experimentalRuntimeMode: (_f = vueOptions.experimentalRuntimeMode) !== null && _f !== void 0 ? _f : 'runtime-dom', experimentalDowngradePropsAndEmitsToSetupReturnOnScriptSetup: (_g = vueOptions.experimentalDowngradePropsAndEmitsToSetupReturnOnScriptSetup) !== null && _g !== void 0 ? _g : 'onlyJs', experimentalTemplateCompilerOptions: (_h = vueOptions.experimentalTemplateCompilerOptions) !== null && _h !== void 0 ? _h : {}, experimentalTemplateCompilerOptionsRequirePath: (_j = vueOptions.experimentalTemplateCompilerOptionsRequirePath) !== null && _j !== void 0 ? _j : undefined, experimentalDisableTemplateSupport: (_k = vueOptions.experimentalDisableTemplateSupport) !== null && _k !== void 0 ? _k : false, experimentalResolveStyleCssClasses: (_l = vueOptions.experimentalResolveStyleCssClasses) !== null && _l !== void 0 ? _l : 'scoped', experimentalAllowTypeNarrowingInInlineHandlers: (_m = vueOptions.experimentalAllowTypeNarrowingInInlineHandlers) !== null && _m !== void 0 ? _m : false }); | ||
} | ||
@@ -45,0 +48,0 @@ exports.getVueCompilerOptions = getVueCompilerOptions; |
{ | ||
"name": "@volar/vue-language-core", | ||
"version": "0.40.6", | ||
"version": "0.40.7", | ||
"main": "out/index.js", | ||
@@ -16,8 +16,8 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@volar/pug-language-service": "0.40.6", | ||
"@volar/pug-language-service": "0.40.7", | ||
"typescript": "latest" | ||
}, | ||
"dependencies": { | ||
"@volar/code-gen": "0.40.6", | ||
"@volar/source-map": "0.40.6", | ||
"@volar/code-gen": "0.40.7", | ||
"@volar/source-map": "0.40.7", | ||
"@vue/compiler-core": "^3.2.37", | ||
@@ -32,3 +32,3 @@ "@vue/compiler-dom": "^3.2.37", | ||
}, | ||
"gitHead": "f87049a1b54a7b64522b8f8742a5f68baba650d2" | ||
"gitHead": "09b517f887c1024a79ea991181e7d06c7f758941" | ||
} |
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
253744
5486
+ Added@volar/code-gen@0.40.7(transitive)
+ Added@volar/source-map@0.40.7(transitive)
- Removed@volar/code-gen@0.40.6(transitive)
- Removed@volar/source-map@0.40.6(transitive)
Updated@volar/code-gen@0.40.7
Updated@volar/source-map@0.40.7