@vue/language-core 2.2.10 → 3.0.0-alpha.10
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/index.d.ts +1 -2
- package/index.js +1 -1
- package/lib/codegen/codeFeatures.d.ts +5 -0
- package/lib/codegen/codeFeatures.js +5 -0
- package/lib/codegen/globalTypes.js +44 -31
- package/lib/codegen/localTypes.d.ts +2 -3
- package/lib/codegen/localTypes.js +5 -15
- package/lib/codegen/script/component.js +21 -9
- package/lib/codegen/script/context.d.ts +1 -1
- package/lib/codegen/script/context.js +1 -1
- package/lib/codegen/script/index.d.ts +1 -2
- package/lib/codegen/script/index.js +2 -18
- package/lib/codegen/script/scriptSetup.js +5 -16
- package/lib/codegen/script/src.js +4 -22
- package/lib/codegen/script/template.js +7 -6
- package/lib/codegen/template/context.d.ts +29 -19
- package/lib/codegen/template/context.js +87 -56
- package/lib/codegen/template/element.d.ts +2 -2
- package/lib/codegen/template/element.js +34 -63
- package/lib/codegen/template/elementChildren.d.ts +2 -2
- package/lib/codegen/template/elementChildren.js +4 -6
- package/lib/codegen/template/elementDirectives.js +3 -15
- package/lib/codegen/template/elementEvents.d.ts +4 -3
- package/lib/codegen/template/elementEvents.js +61 -29
- package/lib/codegen/template/elementProps.d.ts +2 -2
- package/lib/codegen/template/elementProps.js +11 -22
- package/lib/codegen/template/index.d.ts +1 -2
- package/lib/codegen/template/index.js +22 -11
- package/lib/codegen/template/interpolation.d.ts +1 -1
- package/lib/codegen/template/interpolation.js +53 -51
- package/lib/codegen/template/slotOutlet.js +2 -3
- package/lib/codegen/template/styleScopedClasses.js +2 -2
- package/lib/codegen/template/templateChild.d.ts +1 -1
- package/lib/codegen/template/templateChild.js +12 -46
- package/lib/codegen/template/vFor.js +5 -10
- package/lib/codegen/template/vIf.js +2 -10
- package/lib/codegen/template/vSlot.d.ts +1 -2
- package/lib/codegen/template/vSlot.js +111 -59
- package/lib/codegen/utils/index.d.ts +2 -3
- package/lib/codegen/utils/index.js +2 -18
- package/lib/languagePlugin.d.ts +1 -1
- package/lib/languagePlugin.js +1 -7
- package/lib/parsers/scriptRanges.d.ts +2 -3
- package/lib/parsers/scriptRanges.js +10 -13
- package/lib/parsers/scriptSetupRanges.d.ts +0 -3
- package/lib/parsers/scriptSetupRanges.js +36 -43
- package/lib/plugins/file-md.js +3 -0
- package/lib/plugins/vue-style-css.d.ts +3 -0
- package/lib/plugins/vue-style-css.js +18 -0
- package/lib/plugins/vue-template-inline-css.js +1 -1
- package/lib/plugins/vue-template-inline-ts.js +5 -2
- package/lib/plugins/vue-tsx.d.ts +27 -18
- package/lib/plugins/vue-tsx.js +32 -24
- package/lib/plugins.d.ts +1 -1
- package/lib/types.d.ts +3 -2
- package/lib/utils/shared.d.ts +4 -1
- package/lib/utils/shared.js +12 -4
- package/lib/utils/signals.d.ts +1 -0
- package/lib/utils/signals.js +11 -0
- package/lib/utils/ts.d.ts +0 -4
- package/lib/utils/ts.js +4 -14
- package/lib/virtualFile/computedSfc.js +6 -6
- package/package.json +6 -8
- package/lib/utils/vue2TemplateCompiler.d.ts +0 -2
- package/lib/utils/vue2TemplateCompiler.js +0 -89
|
@@ -7,9 +7,9 @@ const parseCssVars_1 = require("../utils/parseCssVars");
|
|
|
7
7
|
const signals_1 = require("../utils/signals");
|
|
8
8
|
function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
|
|
9
9
|
const getUntrackedSnapshot = () => {
|
|
10
|
-
(0, alien_signals_1.
|
|
10
|
+
const pausedSub = (0, alien_signals_1.setCurrentSub)(undefined);
|
|
11
11
|
const res = getSnapshot();
|
|
12
|
-
(0, alien_signals_1.
|
|
12
|
+
(0, alien_signals_1.setCurrentSub)(pausedSub);
|
|
13
13
|
return res;
|
|
14
14
|
};
|
|
15
15
|
const getContent = (0, alien_signals_1.computed)(() => {
|
|
@@ -88,8 +88,8 @@ function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
|
|
|
88
88
|
const base = computedSfcBlock('style_' + i, 'css', getBlock);
|
|
89
89
|
const getModule = computedAttrValue('__module', base, getBlock);
|
|
90
90
|
const getScoped = (0, alien_signals_1.computed)(() => !!getBlock().scoped);
|
|
91
|
-
const getCssVars = (0,
|
|
92
|
-
const getClassNames = (0,
|
|
91
|
+
const getCssVars = (0, signals_1.computedItems)(() => [...(0, parseCssVars_1.parseCssVars)(base.content)], (oldItem, newItem) => oldItem.text === newItem.text && oldItem.offset === newItem.offset);
|
|
92
|
+
const getClassNames = (0, signals_1.computedItems)(() => [...(0, parseCssClassNames_1.parseCssClassNames)(base.content)], (oldItem, newItem) => oldItem.text === newItem.text && oldItem.offset === newItem.offset);
|
|
93
93
|
return () => mergeObject(base, {
|
|
94
94
|
get module() { return getModule(); },
|
|
95
95
|
get scoped() { return getScoped(); },
|
|
@@ -127,9 +127,9 @@ function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
|
|
|
127
127
|
if (cache?.plugin.updateSFCTemplate) {
|
|
128
128
|
const change = getUntrackedSnapshot().getChangeRange(cache.snapshot);
|
|
129
129
|
if (change) {
|
|
130
|
-
(0, alien_signals_1.
|
|
130
|
+
const pausedSub = (0, alien_signals_1.setCurrentSub)(undefined);
|
|
131
131
|
const templateOffset = base.startTagEnd;
|
|
132
|
-
(0, alien_signals_1.
|
|
132
|
+
(0, alien_signals_1.setCurrentSub)(pausedSub);
|
|
133
133
|
const newText = getUntrackedSnapshot().getText(change.span.start, change.span.start + change.newLength);
|
|
134
134
|
const newResult = cache.plugin.updateSFCTemplate(cache.result, {
|
|
135
135
|
start: change.span.start - templateOffset,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -13,20 +13,18 @@
|
|
|
13
13
|
"directory": "packages/language-core"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "~2.4.
|
|
16
|
+
"@volar/language-core": "~2.4.13",
|
|
17
17
|
"@vue/compiler-dom": "^3.5.0",
|
|
18
|
-
"@vue/compiler-vue2": "^2.7.16",
|
|
19
18
|
"@vue/shared": "^3.5.0",
|
|
20
|
-
"alien-signals": "^
|
|
21
|
-
"minimatch": "^
|
|
19
|
+
"alien-signals": "^2.0.5",
|
|
20
|
+
"minimatch": "^10.0.1",
|
|
22
21
|
"muggle-string": "^0.4.1",
|
|
23
22
|
"path-browserify": "^1.0.1"
|
|
24
23
|
},
|
|
25
24
|
"devDependencies": {
|
|
26
|
-
"@types/minimatch": "^5.1.2",
|
|
27
25
|
"@types/node": "^22.10.4",
|
|
28
26
|
"@types/path-browserify": "^1.0.1",
|
|
29
|
-
"@volar/typescript": "~2.4.
|
|
27
|
+
"@volar/typescript": "~2.4.13",
|
|
30
28
|
"@vue/compiler-sfc": "^3.5.0"
|
|
31
29
|
},
|
|
32
30
|
"peerDependencies": {
|
|
@@ -37,5 +35,5 @@
|
|
|
37
35
|
"optional": true
|
|
38
36
|
}
|
|
39
37
|
},
|
|
40
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "28308b4f76cc80c7632f39ae7e0944f1889661a2"
|
|
41
39
|
}
|
|
@@ -1,89 +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 ?? error.start },
|
|
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 ?? error.start },
|
|
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 => { throw error; });
|
|
61
|
-
const isModuleMode = options.mode === 'module';
|
|
62
|
-
const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode;
|
|
63
|
-
if (!prefixIdentifiers && options.cacheHandlers) {
|
|
64
|
-
onError(CompilerDOM.createCompilerError(49));
|
|
65
|
-
}
|
|
66
|
-
if (options.scopeId && !isModuleMode) {
|
|
67
|
-
onError(CompilerDOM.createCompilerError(50));
|
|
68
|
-
}
|
|
69
|
-
const ast = CompilerDOM.baseParse(template, options);
|
|
70
|
-
const [nodeTransforms, directiveTransforms] = CompilerDOM.getBaseTransformPreset(prefixIdentifiers);
|
|
71
|
-
// v-for > v-if in vue 2
|
|
72
|
-
const transformIf = nodeTransforms[1];
|
|
73
|
-
const transformFor = nodeTransforms[3];
|
|
74
|
-
nodeTransforms[1] = transformFor;
|
|
75
|
-
nodeTransforms[3] = transformIf;
|
|
76
|
-
CompilerDOM.transform(ast, Object.assign({}, options, {
|
|
77
|
-
prefixIdentifiers,
|
|
78
|
-
nodeTransforms: [
|
|
79
|
-
...nodeTransforms,
|
|
80
|
-
...(options.nodeTransforms || []) // user transforms
|
|
81
|
-
],
|
|
82
|
-
directiveTransforms: Object.assign({}, directiveTransforms, options.directiveTransforms || {} // user transforms
|
|
83
|
-
)
|
|
84
|
-
}));
|
|
85
|
-
return CompilerDOM.generate(ast, Object.assign({}, options, {
|
|
86
|
-
prefixIdentifiers
|
|
87
|
-
}));
|
|
88
|
-
}
|
|
89
|
-
//# sourceMappingURL=vue2TemplateCompiler.js.map
|