@vue/language-core 3.0.8 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/codegen/globalTypes.js +19 -13
- package/lib/codegen/localTypes.d.ts +2 -4
- package/lib/codegen/localTypes.js +10 -33
- package/lib/codegen/script/component.d.ts +0 -3
- package/lib/codegen/script/component.js +15 -22
- package/lib/codegen/script/context.d.ts +2 -4
- package/lib/codegen/script/index.d.ts +4 -6
- package/lib/codegen/script/index.js +70 -59
- package/lib/codegen/script/scriptSetup.js +140 -141
- package/lib/codegen/script/template.d.ts +1 -3
- package/lib/codegen/script/template.js +90 -16
- package/lib/codegen/template/context.js +1 -1
- package/lib/codegen/template/element.js +1 -3
- package/lib/codegen/template/elementProps.js +2 -6
- package/lib/codegen/template/index.d.ts +1 -1
- package/lib/codegen/template/index.js +10 -10
- package/lib/codegen/utils/index.d.ts +1 -0
- package/lib/codegen/utils/index.js +7 -0
- package/lib/compilerOptions.js +1 -3
- package/lib/languagePlugin.js +8 -19
- package/lib/parsers/scriptRanges.d.ts +0 -1
- package/lib/parsers/scriptRanges.js +6 -9
- package/lib/parsers/scriptSetupRanges.d.ts +0 -6
- package/lib/parsers/scriptSetupRanges.js +7 -93
- package/lib/parsers/utils.d.ts +12 -0
- package/lib/parsers/utils.js +95 -0
- package/lib/plugins/vue-tsx.d.ts +2 -5
- package/lib/plugins/vue-tsx.js +15 -10
- package/lib/types.d.ts +1 -1
- package/lib/utils/shared.d.ts +0 -1
- package/lib/utils/shared.js +0 -4
- package/lib/virtualFile/computedSfc.js +4 -4
- package/package.json +3 -4
- package/lib/codegen/script/componentSelf.d.ts +0 -5
- package/lib/codegen/script/componentSelf.js +0 -53
- package/lib/utils/vue2TemplateCompiler.d.ts +0 -2
- package/lib/utils/vue2TemplateCompiler.js +0 -90
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.compile = void 0;
|
|
4
|
-
const CompilerDOM = require("@vue/compiler-dom");
|
|
5
|
-
const Vue2TemplateCompiler = require('@vue/compiler-vue2/build');
|
|
6
|
-
const compile = (template, options = {}) => {
|
|
7
|
-
if (typeof template !== 'string') {
|
|
8
|
-
throw new Error(`[@vue/language-core] compile() first argument must be string.`);
|
|
9
|
-
}
|
|
10
|
-
const onError = options.onError;
|
|
11
|
-
const onWarn = options.onWarn;
|
|
12
|
-
options.onError = error => {
|
|
13
|
-
if (error.code === 33 // :key binding allowed in v-for template child in vue 2
|
|
14
|
-
|| error.code === 29 // fix https://github.com/vuejs/language-tools/issues/1638
|
|
15
|
-
) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (onError) {
|
|
19
|
-
onError(error);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
throw error;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
const vue2Result = Vue2TemplateCompiler.compile(template, { outputSourceRange: true });
|
|
26
|
-
for (const error of vue2Result.errors) {
|
|
27
|
-
onError?.({
|
|
28
|
-
code: 'vue-template-compiler',
|
|
29
|
-
name: '',
|
|
30
|
-
message: error.msg,
|
|
31
|
-
loc: {
|
|
32
|
-
source: '',
|
|
33
|
-
start: { column: -1, line: -1, offset: error.start },
|
|
34
|
-
end: { column: -1, line: -1, offset: error.end },
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
for (const error of vue2Result.tips) {
|
|
39
|
-
onWarn?.({
|
|
40
|
-
code: 'vue-template-compiler',
|
|
41
|
-
name: '',
|
|
42
|
-
message: error.msg,
|
|
43
|
-
loc: {
|
|
44
|
-
source: '',
|
|
45
|
-
start: { column: -1, line: -1, offset: error.start },
|
|
46
|
-
end: { column: -1, line: -1, offset: error.end },
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return baseCompile(template, Object.assign({}, CompilerDOM.parserOptions, options, {
|
|
51
|
-
nodeTransforms: [
|
|
52
|
-
...CompilerDOM.DOMNodeTransforms,
|
|
53
|
-
...(options.nodeTransforms || []),
|
|
54
|
-
],
|
|
55
|
-
directiveTransforms: Object.assign({}, CompilerDOM.DOMDirectiveTransforms, options.directiveTransforms || {}),
|
|
56
|
-
}));
|
|
57
|
-
};
|
|
58
|
-
exports.compile = compile;
|
|
59
|
-
function baseCompile(template, options = {}) {
|
|
60
|
-
const onError = options.onError || (error => {
|
|
61
|
-
throw error;
|
|
62
|
-
});
|
|
63
|
-
const isModuleMode = options.mode === 'module';
|
|
64
|
-
const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode;
|
|
65
|
-
if (!prefixIdentifiers && options.cacheHandlers) {
|
|
66
|
-
onError(CompilerDOM.createCompilerError(49));
|
|
67
|
-
}
|
|
68
|
-
if (options.scopeId && !isModuleMode) {
|
|
69
|
-
onError(CompilerDOM.createCompilerError(50));
|
|
70
|
-
}
|
|
71
|
-
const ast = CompilerDOM.baseParse(template, options);
|
|
72
|
-
const [nodeTransforms, directiveTransforms] = CompilerDOM.getBaseTransformPreset(prefixIdentifiers);
|
|
73
|
-
// v-for > v-if in vue 2
|
|
74
|
-
const transformIf = nodeTransforms[1];
|
|
75
|
-
const transformFor = nodeTransforms[3];
|
|
76
|
-
nodeTransforms[1] = transformFor;
|
|
77
|
-
nodeTransforms[3] = transformIf;
|
|
78
|
-
CompilerDOM.transform(ast, Object.assign({}, options, {
|
|
79
|
-
prefixIdentifiers,
|
|
80
|
-
nodeTransforms: [
|
|
81
|
-
...nodeTransforms,
|
|
82
|
-
...(options.nodeTransforms || []), // user transforms
|
|
83
|
-
],
|
|
84
|
-
directiveTransforms: Object.assign({}, directiveTransforms, options.directiveTransforms || {}),
|
|
85
|
-
}));
|
|
86
|
-
return CompilerDOM.generate(ast, Object.assign({}, options, {
|
|
87
|
-
prefixIdentifiers,
|
|
88
|
-
}));
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=vue2TemplateCompiler.js.map
|