@volar/vue-language-core
Advanced tools
Comparing version 1.0.0-alpha.1 to 1.0.0-alpha.2
import { CodeGen } from '@volar/code-gen'; | ||
import * as CompilerCore from '@vue/compiler-core'; | ||
import * as CompilerDOM from '@vue/compiler-dom'; | ||
@@ -16,2 +15,2 @@ import { EmbeddedFileMappingData } from '../sourceFile'; | ||
export declare function walkElementNodes(node: CompilerDOM.RootNode | CompilerDOM.TemplateChildNode, cb: (node: CompilerDOM.ElementNode) => void): void; | ||
export declare function getPatchForSlotNode(node: CompilerDOM.ElementNode): CompilerCore.ForNode | undefined; | ||
export declare function getPatchForSlotNode(node: CompilerDOM.ElementNode): CompilerDOM.ForNode | undefined; |
@@ -14,2 +14,2 @@ export * from './utils/string'; | ||
export * as _0 from '@vue/compiler-sfc'; | ||
export * as _1 from '@vue/compiler-core'; | ||
export * as _1 from '@vue/compiler-dom'; |
@@ -31,3 +31,3 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
exports._0 = require("@vue/compiler-sfc"); | ||
exports._1 = require("@vue/compiler-core"); | ||
exports._1 = require("@vue/compiler-dom"); | ||
//# sourceMappingURL=index.js.map |
const presetInitialIndentBrackets = { | ||
css: ['{', '}'], | ||
scss: ['{', '}'], | ||
less: ['{', '}'], | ||
}; | ||
@@ -5,0 +6,0 @@ const plugin = () => { |
@@ -18,19 +18,41 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
const CompilerDom = require("@vue/compiler-dom"); | ||
const CompilerCore = require("@vue/compiler-core"); | ||
const Vue2TemplateCompiler = require('vue-template-compiler/build'); | ||
__exportStar(require("@vue/compiler-dom"), exports); | ||
function compile(template, options = {}) { | ||
var _a, _b; | ||
const onError = options.onError; | ||
const onWarn = options.onWarn; | ||
options.onError = (error) => { | ||
if (error.code === 33 /* CompilerCore.ErrorCodes.X_V_FOR_TEMPLATE_KEY_PLACEMENT */ // :key binding allowed in v-for template child in vue 2 | ||
|| error.code === 29 /* CompilerCore.ErrorCodes.X_V_IF_SAME_KEY */ // fix https://github.com/johnsoncodehk/volar/issues/1638 | ||
) { | ||
return; | ||
} | ||
if (onError) { | ||
onError(error); | ||
} | ||
else { | ||
throw error; | ||
} | ||
// ignore all error for baseCompile | ||
return; | ||
}; | ||
options.onWarn = (error) => { | ||
// ignore all error for baseCompile | ||
return; | ||
}; | ||
const vue2Result = Vue2TemplateCompiler.compile(template, { outputSourceRange: true }); | ||
for (const error of vue2Result.errors) { | ||
onError === null || onError === void 0 ? void 0 : onError({ | ||
code: '', | ||
name: '', | ||
message: error.msg, | ||
loc: { | ||
source: '', | ||
start: { column: -1, line: -1, offset: error.start }, | ||
end: { column: -1, line: -1, offset: (_a = error.end) !== null && _a !== void 0 ? _a : error.start }, | ||
}, | ||
}); | ||
} | ||
for (const error of vue2Result.tips) { | ||
onWarn === null || onWarn === void 0 ? void 0 : onWarn({ | ||
code: '', | ||
name: '', | ||
message: error.msg, | ||
loc: { | ||
source: '', | ||
start: { column: -1, line: -1, offset: error.start }, | ||
end: { column: -1, line: -1, offset: (_b = error.end) !== null && _b !== void 0 ? _b : error.start }, | ||
}, | ||
}); | ||
} | ||
return baseCompile(template, Object.assign({}, CompilerDom.parserOptions, options, { | ||
@@ -50,9 +72,9 @@ nodeTransforms: [ | ||
if (!prefixIdentifiers && options.cacheHandlers) { | ||
onError(CompilerCore.createCompilerError(48 /* CompilerCore.ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */)); | ||
onError(CompilerDom.createCompilerError(48 /* CompilerDom.ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */)); | ||
} | ||
if (options.scopeId && !isModuleMode) { | ||
onError(CompilerCore.createCompilerError(49 /* CompilerCore.ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */)); | ||
onError(CompilerDom.createCompilerError(49 /* CompilerDom.ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */)); | ||
} | ||
const ast = CompilerCore.baseParse(template, options); | ||
const [nodeTransforms, directiveTransforms] = CompilerCore.getBaseTransformPreset(prefixIdentifiers); | ||
const ast = CompilerDom.baseParse(template, options); | ||
const [nodeTransforms, directiveTransforms] = CompilerDom.getBaseTransformPreset(prefixIdentifiers); | ||
// v-for > v-if in vue 2 | ||
@@ -63,3 +85,3 @@ const transformIf = nodeTransforms[1]; | ||
nodeTransforms[3] = transformIf; | ||
CompilerCore.transform(ast, Object.assign({}, options, { | ||
CompilerDom.transform(ast, Object.assign({}, options, { | ||
prefixIdentifiers, | ||
@@ -73,3 +95,3 @@ nodeTransforms: [ | ||
})); | ||
return CompilerCore.generate(ast, Object.assign({}, options, { | ||
return CompilerDom.generate(ast, Object.assign({}, options, { | ||
prefixIdentifiers | ||
@@ -76,0 +98,0 @@ })); |
{ | ||
"name": "@volar/vue-language-core", | ||
"version": "1.0.0-alpha.1", | ||
"version": "1.0.0-alpha.2", | ||
"main": "out/index.js", | ||
@@ -19,12 +19,12 @@ "license": "MIT", | ||
"dependencies": { | ||
"@volar/code-gen": "1.0.0-alpha.1", | ||
"@volar/language-core": "1.0.0-alpha.1", | ||
"@volar/source-map": "1.0.0-alpha.1", | ||
"@vue/compiler-core": "^3.2.38", | ||
"@volar/code-gen": "1.0.0-alpha.2", | ||
"@volar/language-core": "1.0.0-alpha.2", | ||
"@volar/source-map": "1.0.0-alpha.2", | ||
"@vue/compiler-dom": "^3.2.38", | ||
"@vue/compiler-sfc": "^3.2.38", | ||
"@vue/reactivity": "^3.2.38", | ||
"@vue/shared": "^3.2.38" | ||
"@vue/shared": "^3.2.38", | ||
"vue-template-compiler": "^2.7.10" | ||
}, | ||
"gitHead": "3dfd4076f0ca0aa88867ba4fea2979a32ca74ffc" | ||
"gitHead": "6489dfbbc61c4792f7d385ad32d438910ba2c4de" | ||
} |
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
238325
5088
+ Added@volar/code-gen@1.0.0-alpha.2(transitive)
+ Added@volar/language-core@1.0.0-alpha.2(transitive)
+ Added@volar/source-map@1.0.0-alpha.2(transitive)
+ Addedde-indent@1.0.2(transitive)
+ Addedhe@1.2.0(transitive)
+ Addedvue-template-compiler@2.7.16(transitive)
- Removed@vue/compiler-core@^3.2.38
- Removed@volar/code-gen@1.0.0-alpha.1(transitive)
- Removed@volar/language-core@1.0.0-alpha.1(transitive)
- Removed@volar/source-map@1.0.0-alpha.1(transitive)