@vue/language-core 2.1.6 → 2.1.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/lib/codegen/common.d.ts +2 -2
- package/lib/codegen/common.js +8 -10
- package/lib/codegen/globalTypes.js +10 -7
- package/lib/codegen/{types.d.ts → inlayHints.d.ts} +2 -0
- package/lib/codegen/inlayHints.js +17 -0
- package/lib/codegen/script/component.d.ts +1 -1
- package/lib/codegen/script/component.js +8 -5
- package/lib/codegen/script/componentSelf.js +3 -2
- package/lib/codegen/script/context.d.ts +1 -1
- package/lib/codegen/script/index.d.ts +2 -1
- package/lib/codegen/script/index.js +28 -10
- package/lib/codegen/script/scriptSetup.js +107 -112
- package/lib/codegen/script/styleModulesType.js +4 -6
- package/lib/codegen/script/template.d.ts +1 -1
- package/lib/codegen/script/template.js +13 -14
- package/lib/codegen/template/context.d.ts +3 -2
- package/lib/codegen/template/context.js +1 -0
- package/lib/codegen/template/element.d.ts +1 -1
- package/lib/codegen/template/element.js +31 -11
- package/lib/codegen/template/elementDirectives.js +63 -31
- package/lib/codegen/template/elementProps.js +7 -17
- package/lib/codegen/template/index.d.ts +1 -0
- package/lib/codegen/template/index.js +63 -53
- package/lib/codegen/template/interpolation.d.ts +1 -1
- package/lib/codegen/template/interpolation.js +34 -28
- package/lib/codegen/template/slotOutlet.js +5 -0
- package/lib/codegen/template/templateChild.d.ts +1 -1
- package/lib/codegen/template/templateChild.js +6 -2
- package/lib/codegen/template/vFor.js +1 -1
- package/lib/parsers/scriptSetupRanges.d.ts +17 -5
- package/lib/parsers/scriptSetupRanges.js +43 -27
- package/lib/plugins/vue-tsx.d.ts +30 -17
- package/lib/plugins/vue-tsx.js +44 -33
- package/lib/types.d.ts +3 -1
- package/lib/utils/parseCssClassNames.d.ts +1 -1
- package/lib/utils/parseCssClassNames.js +5 -4
- package/lib/utils/parseCssVars.d.ts +3 -2
- package/lib/utils/parseCssVars.js +12 -11
- package/lib/utils/ts.d.ts +1 -1
- package/lib/utils/ts.js +3 -5
- package/lib/virtualFile/computedEmbeddedCodes.d.ts +2 -1
- package/lib/virtualFile/computedEmbeddedCodes.js +11 -11
- package/lib/virtualFile/computedSfc.d.ts +2 -1
- package/lib/virtualFile/computedSfc.js +77 -76
- package/lib/virtualFile/computedVueSfc.d.ts +2 -1
- package/lib/virtualFile/computedVueSfc.js +8 -8
- package/lib/virtualFile/vueFile.d.ts +6 -7
- package/lib/virtualFile/vueFile.js +13 -12
- package/package.json +9 -8
- package/lib/codegen/types.js +0 -3
package/lib/types.d.ts
CHANGED
|
@@ -45,7 +45,9 @@ export interface VueCompilerOptions {
|
|
|
45
45
|
experimentalDefinePropProposal: 'kevinEdition' | 'johnsonEdition' | false;
|
|
46
46
|
experimentalResolveStyleCssClasses: 'scoped' | 'always' | 'never';
|
|
47
47
|
experimentalModelPropName: Record<string, Record<string, boolean | Record<string, string> | Record<string, string>[]>>;
|
|
48
|
-
__setupedGlobalTypes?:
|
|
48
|
+
__setupedGlobalTypes?: true | {
|
|
49
|
+
absolutePath: string;
|
|
50
|
+
};
|
|
49
51
|
__test?: boolean;
|
|
50
52
|
}
|
|
51
53
|
export declare const validVersions: readonly [2, 2.1];
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseCssClassNames = parseCssClassNames;
|
|
4
4
|
const parseCssVars_1 = require("./parseCssVars");
|
|
5
|
-
const cssClassNameReg = /(?=(\.[a-z_][-\w]*)[\s.,+~>:#[{])/gi;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const cssClassNameReg = /(?=(\.[a-z_][-\w]*)[\s.,+~>:#)[{])/gi;
|
|
6
|
+
const fragmentReg = /(?<={)[^{]*(?=(?<!\\);)/g;
|
|
7
|
+
function* parseCssClassNames(css) {
|
|
8
|
+
css = (0, parseCssVars_1.fillBlank)(css, parseCssVars_1.commentReg, fragmentReg);
|
|
9
|
+
const matches = css.matchAll(cssClassNameReg);
|
|
9
10
|
for (const match of matches) {
|
|
10
11
|
const matchText = match[1];
|
|
11
12
|
if (matchText) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare const commentReg: RegExp;
|
|
2
|
+
export declare function parseCssVars(css: string): Generator<{
|
|
2
3
|
offset: number;
|
|
3
4
|
text: string;
|
|
4
5
|
}, void, unknown>;
|
|
5
|
-
export declare function
|
|
6
|
+
export declare function fillBlank(css: string, ...regs: RegExp[]): string;
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// https://github.com/vuejs/core/blob/main/packages/compiler-sfc/src/cssVars.ts#L47-L61
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.commentReg = void 0;
|
|
4
5
|
exports.parseCssVars = parseCssVars;
|
|
5
|
-
exports.
|
|
6
|
+
exports.fillBlank = fillBlank;
|
|
6
7
|
const vBindCssVarReg = /\bv-bind\(\s*(?:'([^']+)'|"([^"]+)"|([a-z_]\w*))\s*\)/gi;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const matchs = styleContent.matchAll(vBindCssVarReg);
|
|
8
|
+
exports.commentReg = /(?<=\/\*)[\s\S]*?(?=\*\/)|(?<=\/\/)[\s\S]*?(?=\n)/g;
|
|
9
|
+
function* parseCssVars(css) {
|
|
10
|
+
css = fillBlank(css, exports.commentReg);
|
|
11
|
+
const matchs = css.matchAll(vBindCssVarReg);
|
|
12
12
|
for (const match of matchs) {
|
|
13
13
|
const matchText = match.slice(1).find(t => t);
|
|
14
14
|
if (matchText) {
|
|
15
|
-
const offset = match.index +
|
|
15
|
+
const offset = match.index + css.slice(match.index).indexOf(matchText);
|
|
16
16
|
yield { offset, text: matchText };
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
.replace(
|
|
23
|
-
|
|
20
|
+
function fillBlank(css, ...regs) {
|
|
21
|
+
for (const reg of regs) {
|
|
22
|
+
css = css.replace(reg, match => ' '.repeat(match.length));
|
|
23
|
+
}
|
|
24
|
+
return css;
|
|
24
25
|
}
|
|
25
26
|
//# sourceMappingURL=parseCssVars.js.map
|
package/lib/utils/ts.d.ts
CHANGED
|
@@ -11,4 +11,4 @@ export declare function resolveVueCompilerOptions(vueOptions: Partial<VueCompile
|
|
|
11
11
|
export declare function setupGlobalTypes(rootDir: string, vueOptions: VueCompilerOptions, host: {
|
|
12
12
|
fileExists(path: string): boolean;
|
|
13
13
|
writeFile?(path: string, data: string): void;
|
|
14
|
-
}):
|
|
14
|
+
}): VueCompilerOptions['__setupedGlobalTypes'];
|
package/lib/utils/ts.js
CHANGED
|
@@ -222,7 +222,7 @@ function resolveVueCompilerOptions(vueOptions) {
|
|
|
222
222
|
}
|
|
223
223
|
function setupGlobalTypes(rootDir, vueOptions, host) {
|
|
224
224
|
if (!host.writeFile) {
|
|
225
|
-
return
|
|
225
|
+
return;
|
|
226
226
|
}
|
|
227
227
|
try {
|
|
228
228
|
let dir = rootDir;
|
|
@@ -236,10 +236,8 @@ function setupGlobalTypes(rootDir, vueOptions, host) {
|
|
|
236
236
|
const globalTypesPath = path_browserify_1.posix.join(dir, 'node_modules', '.vue-global-types', `${vueOptions.lib}_${vueOptions.target}_${vueOptions.strictTemplates}.d.ts`);
|
|
237
237
|
const globalTypesContents = `// @ts-nocheck\nexport {};\n` + (0, globalTypes_1.generateGlobalTypes)(vueOptions.lib, vueOptions.target, vueOptions.strictTemplates);
|
|
238
238
|
host.writeFile(globalTypesPath, globalTypesContents);
|
|
239
|
-
return
|
|
240
|
-
}
|
|
241
|
-
catch {
|
|
242
|
-
return false;
|
|
239
|
+
return { absolutePath: globalTypesPath };
|
|
243
240
|
}
|
|
241
|
+
catch { }
|
|
244
242
|
}
|
|
245
243
|
//# sourceMappingURL=ts.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { VirtualCode } from '@volar/language-core';
|
|
2
|
+
import { ISignal } from 'alien-signals';
|
|
2
3
|
import type { Sfc, VueLanguagePluginReturn } from '../types';
|
|
3
|
-
export declare function computedEmbeddedCodes(plugins: VueLanguagePluginReturn[], fileName: string, sfc: Sfc):
|
|
4
|
+
export declare function computedEmbeddedCodes(plugins: VueLanguagePluginReturn[], fileName: string, sfc: Sfc): ISignal<VirtualCode[]>;
|
|
4
5
|
export declare function resolveCommonLanguageId(lang: string): string;
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.computedEmbeddedCodes = computedEmbeddedCodes;
|
|
4
4
|
exports.resolveCommonLanguageId = resolveCommonLanguageId;
|
|
5
|
-
const
|
|
5
|
+
const alien_signals_1 = require("alien-signals");
|
|
6
6
|
const muggle_string_1 = require("muggle-string");
|
|
7
7
|
const buildMappings_1 = require("../utils/buildMappings");
|
|
8
8
|
const embeddedFile_1 = require("./embeddedFile");
|
|
9
9
|
function computedEmbeddedCodes(plugins, fileName, sfc) {
|
|
10
|
-
const nameToBlock = (0,
|
|
10
|
+
const nameToBlock = (0, alien_signals_1.computed)(() => {
|
|
11
11
|
const blocks = {};
|
|
12
12
|
if (sfc.template) {
|
|
13
13
|
blocks[sfc.template.name] = sfc.template;
|
|
@@ -27,10 +27,10 @@ function computedEmbeddedCodes(plugins, fileName, sfc) {
|
|
|
27
27
|
return blocks;
|
|
28
28
|
});
|
|
29
29
|
const pluginsResult = plugins.map(plugin => computedPluginEmbeddedCodes(plugins, plugin, fileName, sfc, nameToBlock));
|
|
30
|
-
const flatResult = (0,
|
|
31
|
-
const structuredResult = (0,
|
|
30
|
+
const flatResult = (0, alien_signals_1.computed)(() => pluginsResult.map(r => r.get()).flat());
|
|
31
|
+
const structuredResult = (0, alien_signals_1.computed)(() => {
|
|
32
32
|
const embeddedCodes = [];
|
|
33
|
-
let remain = [...flatResult()];
|
|
33
|
+
let remain = [...flatResult.get()];
|
|
34
34
|
while (remain.length) {
|
|
35
35
|
const beforeLength = remain.length;
|
|
36
36
|
consumeRemain();
|
|
@@ -90,7 +90,7 @@ function computedEmbeddedCodes(plugins, fileName, sfc) {
|
|
|
90
90
|
function computedPluginEmbeddedCodes(plugins, plugin, fileName, sfc, nameToBlock) {
|
|
91
91
|
const computeds = new Map();
|
|
92
92
|
const getComputedKey = (code) => code.id + '__' + code.lang;
|
|
93
|
-
const codes = (0,
|
|
93
|
+
const codes = (0, alien_signals_1.computed)(() => {
|
|
94
94
|
try {
|
|
95
95
|
if (!plugin.getEmbeddedCodes) {
|
|
96
96
|
return [...computeds.values()];
|
|
@@ -103,7 +103,7 @@ function computedPluginEmbeddedCodes(plugins, plugin, fileName, sfc, nameToBlock
|
|
|
103
103
|
}
|
|
104
104
|
for (const codeInfo of embeddedCodeInfos) {
|
|
105
105
|
if (!computeds.has(getComputedKey(codeInfo))) {
|
|
106
|
-
computeds.set(getComputedKey(codeInfo), (0,
|
|
106
|
+
computeds.set(getComputedKey(codeInfo), (0, alien_signals_1.computed)(() => {
|
|
107
107
|
const content = [];
|
|
108
108
|
const code = new embeddedFile_1.VueEmbeddedCode(codeInfo.id, codeInfo.lang, content);
|
|
109
109
|
for (const plugin of plugins) {
|
|
@@ -147,9 +147,9 @@ function computedPluginEmbeddedCodes(plugins, plugin, fileName, sfc, nameToBlock
|
|
|
147
147
|
}
|
|
148
148
|
return [...computeds.values()];
|
|
149
149
|
});
|
|
150
|
-
return (0,
|
|
151
|
-
return codes().map(_file => {
|
|
152
|
-
const { code, snapshot } = _file();
|
|
150
|
+
return (0, alien_signals_1.computed)(() => {
|
|
151
|
+
return codes.get().map(_file => {
|
|
152
|
+
const { code, snapshot } = _file.get();
|
|
153
153
|
const mappings = (0, buildMappings_1.buildMappings)(code.content.map(segment => {
|
|
154
154
|
if (typeof segment === 'string') {
|
|
155
155
|
return segment;
|
|
@@ -158,7 +158,7 @@ function computedPluginEmbeddedCodes(plugins, plugin, fileName, sfc, nameToBlock
|
|
|
158
158
|
if (source === undefined) {
|
|
159
159
|
return segment;
|
|
160
160
|
}
|
|
161
|
-
const block = nameToBlock()[source];
|
|
161
|
+
const block = nameToBlock.get()[source];
|
|
162
162
|
if (!block) {
|
|
163
163
|
// console.warn('Unable to find block: ' + source);
|
|
164
164
|
return segment;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SFCParseResult } from '@vue/compiler-sfc';
|
|
2
|
+
import { ISignal, Signal } from 'alien-signals';
|
|
2
3
|
import type * as ts from 'typescript';
|
|
3
4
|
import type { Sfc, VueLanguagePluginReturn } from '../types';
|
|
4
|
-
export declare function computedSfc(ts: typeof import('typescript'), plugins: VueLanguagePluginReturn[], fileName: string,
|
|
5
|
+
export declare function computedSfc(ts: typeof import('typescript'), plugins: VueLanguagePluginReturn[], fileName: string, snapshot: Signal<ts.IScriptSnapshot>, parsed: ISignal<SFCParseResult | undefined>): Sfc;
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.computedSfc = computedSfc;
|
|
4
|
-
const
|
|
4
|
+
const alien_signals_1 = require("alien-signals");
|
|
5
5
|
const parseCssClassNames_1 = require("../utils/parseCssClassNames");
|
|
6
6
|
const parseCssVars_1 = require("../utils/parseCssVars");
|
|
7
|
-
function computedSfc(ts, plugins, fileName,
|
|
7
|
+
function computedSfc(ts, plugins, fileName, snapshot, parsed) {
|
|
8
8
|
const untrackedSnapshot = () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const prevTrackId = alien_signals_1.System.activeTrackId;
|
|
10
|
+
alien_signals_1.System.activeTrackId = 0;
|
|
11
|
+
const res = snapshot.get();
|
|
12
|
+
alien_signals_1.System.activeTrackId = prevTrackId;
|
|
12
13
|
return res;
|
|
13
14
|
};
|
|
14
|
-
const content = (0,
|
|
15
|
-
|
|
16
|
-
return snapshot.getText(0, snapshot.getLength());
|
|
15
|
+
const content = (0, alien_signals_1.computed)(() => {
|
|
16
|
+
return snapshot.get().getText(0, snapshot.get().getLength());
|
|
17
17
|
});
|
|
18
|
-
const template = computedNullableSfcBlock('template', 'html', (0,
|
|
18
|
+
const template = computedNullableSfcBlock('template', 'html', (0, alien_signals_1.computed)(() => parsed.get()?.descriptor.template ?? undefined), (_block, base) => {
|
|
19
19
|
const compiledAst = computedTemplateAst(base);
|
|
20
20
|
return mergeObject(base, {
|
|
21
|
-
get ast() { return compiledAst()?.ast; },
|
|
22
|
-
get errors() { return compiledAst()?.errors; },
|
|
23
|
-
get warnings() { return compiledAst()?.warnings; },
|
|
21
|
+
get ast() { return compiledAst.get()?.ast; },
|
|
22
|
+
get errors() { return compiledAst.get()?.errors; },
|
|
23
|
+
get warnings() { return compiledAst.get()?.warnings; },
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
|
-
const script = computedNullableSfcBlock('script', 'js', (0,
|
|
27
|
-
const src = (0,
|
|
28
|
-
const srcOffset = (0,
|
|
29
|
-
const _src = src();
|
|
26
|
+
const script = computedNullableSfcBlock('script', 'js', (0, alien_signals_1.computed)(() => parsed.get()?.descriptor.script ?? undefined), (block, base) => {
|
|
27
|
+
const src = (0, alien_signals_1.computed)(() => block.get().src);
|
|
28
|
+
const srcOffset = (0, alien_signals_1.computed)(() => {
|
|
29
|
+
const _src = src.get();
|
|
30
30
|
return _src ? untrackedSnapshot().getText(0, base.startTagEnd).lastIndexOf(_src) - base.startTagEnd : -1;
|
|
31
31
|
});
|
|
32
|
-
const ast = (0,
|
|
32
|
+
const ast = (0, alien_signals_1.computed)(() => {
|
|
33
33
|
for (const plugin of plugins) {
|
|
34
34
|
const ast = plugin.compileSFCScript?.(base.lang, base.content);
|
|
35
35
|
if (ast) {
|
|
@@ -39,21 +39,21 @@ function computedSfc(ts, plugins, fileName, getSnapshot, parsed) {
|
|
|
39
39
|
return ts.createSourceFile(fileName + '.' + base.lang, '', 99);
|
|
40
40
|
});
|
|
41
41
|
return mergeObject(base, {
|
|
42
|
-
get src() { return src(); },
|
|
43
|
-
get srcOffset() { return srcOffset(); },
|
|
44
|
-
get ast() { return ast(); },
|
|
42
|
+
get src() { return src.get(); },
|
|
43
|
+
get srcOffset() { return srcOffset.get(); },
|
|
44
|
+
get ast() { return ast.get(); },
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
|
-
const scriptSetupOriginal = computedNullableSfcBlock('scriptSetup', 'js', (0,
|
|
48
|
-
const generic = (0,
|
|
49
|
-
const _block = block();
|
|
47
|
+
const scriptSetupOriginal = computedNullableSfcBlock('scriptSetup', 'js', (0, alien_signals_1.computed)(() => parsed.get()?.descriptor.scriptSetup ?? undefined), (block, base) => {
|
|
48
|
+
const generic = (0, alien_signals_1.computed)(() => {
|
|
49
|
+
const _block = block.get();
|
|
50
50
|
return typeof _block.attrs.generic === 'string' ? _block.attrs.generic : undefined;
|
|
51
51
|
});
|
|
52
|
-
const genericOffset = (0,
|
|
53
|
-
const _generic = generic();
|
|
52
|
+
const genericOffset = (0, alien_signals_1.computed)(() => {
|
|
53
|
+
const _generic = generic.get();
|
|
54
54
|
return _generic !== undefined ? untrackedSnapshot().getText(0, base.startTagEnd).lastIndexOf(_generic) - base.startTagEnd : -1;
|
|
55
55
|
});
|
|
56
|
-
const ast = (0,
|
|
56
|
+
const ast = (0, alien_signals_1.computed)(() => {
|
|
57
57
|
for (const plugin of plugins) {
|
|
58
58
|
const ast = plugin.compileSFCScript?.(base.lang, base.content);
|
|
59
59
|
if (ast) {
|
|
@@ -63,15 +63,15 @@ function computedSfc(ts, plugins, fileName, getSnapshot, parsed) {
|
|
|
63
63
|
return ts.createSourceFile(fileName + '.' + base.lang, '', 99);
|
|
64
64
|
});
|
|
65
65
|
return mergeObject(base, {
|
|
66
|
-
get generic() { return generic(); },
|
|
67
|
-
get genericOffset() { return genericOffset(); },
|
|
68
|
-
get ast() { return ast(); },
|
|
66
|
+
get generic() { return generic.get(); },
|
|
67
|
+
get genericOffset() { return genericOffset.get(); },
|
|
68
|
+
get ast() { return ast.get(); },
|
|
69
69
|
});
|
|
70
70
|
});
|
|
71
|
-
const hasScript = (0,
|
|
72
|
-
const hasScriptSetup = (0,
|
|
73
|
-
const scriptSetup = (0,
|
|
74
|
-
if (!hasScript() && !hasScriptSetup()) {
|
|
71
|
+
const hasScript = (0, alien_signals_1.computed)(() => !!parsed.get()?.descriptor.script);
|
|
72
|
+
const hasScriptSetup = (0, alien_signals_1.computed)(() => !!parsed.get()?.descriptor.scriptSetup);
|
|
73
|
+
const scriptSetup = (0, alien_signals_1.computed)(() => {
|
|
74
|
+
if (!hasScript.get() && !hasScriptSetup.get()) {
|
|
75
75
|
//#region monkey fix: https://github.com/vuejs/language-tools/pull/2113
|
|
76
76
|
return {
|
|
77
77
|
content: '',
|
|
@@ -87,45 +87,45 @@ function computedSfc(ts, plugins, fileName, getSnapshot, parsed) {
|
|
|
87
87
|
ast: ts.createSourceFile('', '', 99, false, ts.ScriptKind.TS),
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
-
return scriptSetupOriginal();
|
|
90
|
+
return scriptSetupOriginal.get();
|
|
91
91
|
});
|
|
92
|
-
const styles =
|
|
92
|
+
const styles = alien_signals_1.Unstable.computedArray((0, alien_signals_1.computed)(() => parsed.get()?.descriptor.styles ?? []), (block, i) => {
|
|
93
93
|
const base = computedSfcBlock('style_' + i, 'css', block);
|
|
94
|
-
const module = (0,
|
|
95
|
-
const _module = block().module;
|
|
94
|
+
const module = (0, alien_signals_1.computed)(() => {
|
|
95
|
+
const _module = block.get().module;
|
|
96
96
|
return _module ? {
|
|
97
97
|
name: _module.name,
|
|
98
98
|
offset: _module.offset ? base.start + _module.offset : undefined
|
|
99
99
|
} : undefined;
|
|
100
100
|
});
|
|
101
|
-
const scoped = (0,
|
|
102
|
-
const cssVars = (0,
|
|
103
|
-
const classNames = (0,
|
|
104
|
-
return (
|
|
105
|
-
get module() { return module(); },
|
|
106
|
-
get scoped() { return scoped(); },
|
|
107
|
-
get cssVars() { return cssVars(); },
|
|
108
|
-
get classNames() { return classNames(); },
|
|
109
|
-
})
|
|
101
|
+
const scoped = (0, alien_signals_1.computed)(() => !!block.get().scoped);
|
|
102
|
+
const cssVars = (0, alien_signals_1.computed)(() => [...(0, parseCssVars_1.parseCssVars)(base.content)]);
|
|
103
|
+
const classNames = (0, alien_signals_1.computed)(() => [...(0, parseCssClassNames_1.parseCssClassNames)(base.content)]);
|
|
104
|
+
return () => mergeObject(base, {
|
|
105
|
+
get module() { return module.get(); },
|
|
106
|
+
get scoped() { return scoped.get(); },
|
|
107
|
+
get cssVars() { return cssVars.get(); },
|
|
108
|
+
get classNames() { return classNames.get(); },
|
|
109
|
+
});
|
|
110
110
|
});
|
|
111
|
-
const customBlocks =
|
|
111
|
+
const customBlocks = alien_signals_1.Unstable.computedArray((0, alien_signals_1.computed)(() => parsed.get()?.descriptor.customBlocks ?? []), (block, i) => {
|
|
112
112
|
const base = computedSfcBlock('custom_block_' + i, 'txt', block);
|
|
113
|
-
const type = (0,
|
|
114
|
-
return (
|
|
115
|
-
get type() { return type(); },
|
|
116
|
-
})
|
|
113
|
+
const type = (0, alien_signals_1.computed)(() => block.get().type);
|
|
114
|
+
return () => mergeObject(base, {
|
|
115
|
+
get type() { return type.get(); },
|
|
116
|
+
});
|
|
117
117
|
});
|
|
118
118
|
return {
|
|
119
|
-
get content() { return content(); },
|
|
120
|
-
get template() { return template(); },
|
|
121
|
-
get script() { return script(); },
|
|
122
|
-
get scriptSetup() { return scriptSetup(); },
|
|
119
|
+
get content() { return content.get(); },
|
|
120
|
+
get template() { return template.get(); },
|
|
121
|
+
get script() { return script.get(); },
|
|
122
|
+
get scriptSetup() { return scriptSetup.get(); },
|
|
123
123
|
get styles() { return styles; },
|
|
124
124
|
get customBlocks() { return customBlocks; },
|
|
125
125
|
};
|
|
126
126
|
function computedTemplateAst(base) {
|
|
127
127
|
let cache;
|
|
128
|
-
return (0,
|
|
128
|
+
return (0, alien_signals_1.computed)(() => {
|
|
129
129
|
if (cache?.template === base.content) {
|
|
130
130
|
return {
|
|
131
131
|
errors: [],
|
|
@@ -137,9 +137,10 @@ function computedSfc(ts, plugins, fileName, getSnapshot, parsed) {
|
|
|
137
137
|
if (cache?.plugin.updateSFCTemplate) {
|
|
138
138
|
const change = untrackedSnapshot().getChangeRange(cache.snapshot);
|
|
139
139
|
if (change) {
|
|
140
|
-
|
|
140
|
+
const prevTrackId = alien_signals_1.System.activeTrackId;
|
|
141
|
+
alien_signals_1.System.activeTrackId = 0;
|
|
141
142
|
const templateOffset = base.startTagEnd;
|
|
142
|
-
|
|
143
|
+
alien_signals_1.System.activeTrackId = prevTrackId;
|
|
143
144
|
const newText = untrackedSnapshot().getText(change.span.start, change.span.start + change.newLength);
|
|
144
145
|
const newResult = cache.plugin.updateSFCTemplate(cache.result, {
|
|
145
146
|
start: change.span.start - templateOffset,
|
|
@@ -206,32 +207,32 @@ function computedSfc(ts, plugins, fileName, getSnapshot, parsed) {
|
|
|
206
207
|
});
|
|
207
208
|
}
|
|
208
209
|
function computedNullableSfcBlock(name, defaultLang, block, resolve) {
|
|
209
|
-
const hasBlock = (0,
|
|
210
|
-
return (0,
|
|
211
|
-
if (!hasBlock()) {
|
|
210
|
+
const hasBlock = (0, alien_signals_1.computed)(() => !!block.get());
|
|
211
|
+
return (0, alien_signals_1.computed)(() => {
|
|
212
|
+
if (!hasBlock.get()) {
|
|
212
213
|
return;
|
|
213
214
|
}
|
|
214
|
-
const _block = (0,
|
|
215
|
+
const _block = (0, alien_signals_1.computed)(() => block.get());
|
|
215
216
|
return resolve(_block, computedSfcBlock(name, defaultLang, _block));
|
|
216
217
|
});
|
|
217
218
|
}
|
|
218
219
|
function computedSfcBlock(name, defaultLang, block) {
|
|
219
|
-
const lang = (0,
|
|
220
|
-
const attrs = (0,
|
|
221
|
-
const content = (0,
|
|
222
|
-
const startTagEnd = (0,
|
|
223
|
-
const endTagStart = (0,
|
|
224
|
-
const start = (0,
|
|
225
|
-
const end = (0,
|
|
220
|
+
const lang = (0, alien_signals_1.computed)(() => block.get().lang ?? defaultLang);
|
|
221
|
+
const attrs = (0, alien_signals_1.computed)(() => block.get().attrs); // TODO: computed it
|
|
222
|
+
const content = (0, alien_signals_1.computed)(() => block.get().content);
|
|
223
|
+
const startTagEnd = (0, alien_signals_1.computed)(() => block.get().loc.start.offset);
|
|
224
|
+
const endTagStart = (0, alien_signals_1.computed)(() => block.get().loc.end.offset);
|
|
225
|
+
const start = (0, alien_signals_1.computed)(() => untrackedSnapshot().getText(0, startTagEnd.get()).lastIndexOf('<' + block.get().type));
|
|
226
|
+
const end = (0, alien_signals_1.computed)(() => endTagStart.get() + untrackedSnapshot().getText(endTagStart.get(), untrackedSnapshot().getLength()).indexOf('>') + 1);
|
|
226
227
|
return {
|
|
227
228
|
name,
|
|
228
|
-
get lang() { return lang(); },
|
|
229
|
-
get attrs() { return attrs(); },
|
|
230
|
-
get content() { return content(); },
|
|
231
|
-
get startTagEnd() { return startTagEnd(); },
|
|
232
|
-
get endTagStart() { return endTagStart(); },
|
|
233
|
-
get start() { return start(); },
|
|
234
|
-
get end() { return end(); },
|
|
229
|
+
get lang() { return lang.get(); },
|
|
230
|
+
get attrs() { return attrs.get(); },
|
|
231
|
+
get content() { return content.get(); },
|
|
232
|
+
get startTagEnd() { return startTagEnd.get(); },
|
|
233
|
+
get endTagStart() { return endTagStart.get(); },
|
|
234
|
+
get start() { return start.get(); },
|
|
235
|
+
get end() { return end.get(); },
|
|
235
236
|
};
|
|
236
237
|
}
|
|
237
238
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SFCParseResult } from '@vue/compiler-sfc';
|
|
2
|
+
import { Signal } from 'alien-signals';
|
|
2
3
|
import type * as ts from 'typescript';
|
|
3
4
|
import type { VueLanguagePluginReturn } from '../types';
|
|
4
|
-
export declare function computedVueSfc(plugins: VueLanguagePluginReturn[], fileName: string, languageId: string, snapshot:
|
|
5
|
+
export declare function computedVueSfc(plugins: VueLanguagePluginReturn[], fileName: string, languageId: string, snapshot: Signal<ts.IScriptSnapshot>): import("alien-signals").ISignal<SFCParseResult | undefined>;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.computedVueSfc = computedVueSfc;
|
|
4
|
-
const
|
|
4
|
+
const alien_signals_1 = require("alien-signals");
|
|
5
5
|
function computedVueSfc(plugins, fileName, languageId, snapshot) {
|
|
6
6
|
let cache;
|
|
7
|
-
return (0,
|
|
7
|
+
return (0, alien_signals_1.computed)(() => {
|
|
8
8
|
// incremental update
|
|
9
9
|
if (cache?.plugin.updateSFC) {
|
|
10
|
-
const change = snapshot().getChangeRange(cache.snapshot);
|
|
10
|
+
const change = snapshot.get().getChangeRange(cache.snapshot);
|
|
11
11
|
if (change) {
|
|
12
12
|
const newSfc = cache.plugin.updateSFC(cache.sfc, {
|
|
13
13
|
start: change.span.start,
|
|
14
14
|
end: change.span.start + change.span.length,
|
|
15
|
-
newText: snapshot().getText(change.span.start, change.span.start + change.newLength),
|
|
15
|
+
newText: snapshot.get().getText(change.span.start, change.span.start + change.newLength),
|
|
16
16
|
});
|
|
17
17
|
if (newSfc) {
|
|
18
|
-
cache.snapshot = snapshot();
|
|
18
|
+
cache.snapshot = snapshot.get();
|
|
19
19
|
// force dirty
|
|
20
20
|
cache.sfc = JSON.parse(JSON.stringify(newSfc));
|
|
21
21
|
return cache.sfc;
|
|
@@ -23,12 +23,12 @@ function computedVueSfc(plugins, fileName, languageId, snapshot) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
for (const plugin of plugins) {
|
|
26
|
-
const sfc = plugin.parseSFC?.(fileName, snapshot().getText(0, snapshot().getLength()))
|
|
27
|
-
?? plugin.parseSFC2?.(fileName, languageId, snapshot().getText(0, snapshot().getLength()));
|
|
26
|
+
const sfc = plugin.parseSFC?.(fileName, snapshot.get().getText(0, snapshot.get().getLength()))
|
|
27
|
+
?? plugin.parseSFC2?.(fileName, languageId, snapshot.get().getText(0, snapshot.get().getLength()));
|
|
28
28
|
if (sfc) {
|
|
29
29
|
if (!sfc.errors.length) {
|
|
30
30
|
cache = {
|
|
31
|
-
snapshot: snapshot(),
|
|
31
|
+
snapshot: snapshot.get(),
|
|
32
32
|
sfc,
|
|
33
33
|
plugin,
|
|
34
34
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { VirtualCode } from '@volar/language-core';
|
|
2
|
-
import { Signal } from 'computeds';
|
|
3
2
|
import type * as ts from 'typescript';
|
|
4
3
|
import type { VueCompilerOptions, VueLanguagePluginReturn } from '../types';
|
|
5
4
|
export declare class VueVirtualCode implements VirtualCode {
|
|
@@ -10,16 +9,16 @@ export declare class VueVirtualCode implements VirtualCode {
|
|
|
10
9
|
plugins: VueLanguagePluginReturn[];
|
|
11
10
|
ts: typeof import('typescript');
|
|
12
11
|
id: string;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
_snapshot: import("alien-signals").Signal<ts.IScriptSnapshot>;
|
|
13
|
+
_vueSfc: import("alien-signals").ISignal<import("@vue/compiler-sfc").SFCParseResult | undefined>;
|
|
14
|
+
_sfc: import("../types").Sfc;
|
|
15
|
+
_mappings: import("alien-signals").ISignal<{
|
|
17
16
|
sourceOffsets: number[];
|
|
18
17
|
generatedOffsets: number[];
|
|
19
18
|
lengths: number[];
|
|
20
19
|
data: import("@volar/language-core").CodeInformation;
|
|
21
|
-
}[]
|
|
22
|
-
|
|
20
|
+
}[]>;
|
|
21
|
+
_embeddedCodes: import("alien-signals").ISignal<VirtualCode[]>;
|
|
23
22
|
get embeddedCodes(): VirtualCode[];
|
|
24
23
|
get snapshot(): ts.IScriptSnapshot;
|
|
25
24
|
get mappings(): {
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VueVirtualCode = void 0;
|
|
4
|
-
const
|
|
4
|
+
const alien_signals_1 = require("alien-signals");
|
|
5
|
+
const plugins_1 = require("../plugins");
|
|
5
6
|
const computedEmbeddedCodes_1 = require("./computedEmbeddedCodes");
|
|
6
7
|
const computedSfc_1 = require("./computedSfc");
|
|
7
8
|
const computedVueSfc_1 = require("./computedVueSfc");
|
|
8
|
-
const plugins_1 = require("../plugins");
|
|
9
9
|
class VueVirtualCode {
|
|
10
10
|
// others
|
|
11
11
|
get embeddedCodes() {
|
|
12
|
-
return this.
|
|
12
|
+
return this._embeddedCodes.get();
|
|
13
13
|
}
|
|
14
14
|
get snapshot() {
|
|
15
|
-
return this.
|
|
15
|
+
return this._snapshot.get();
|
|
16
16
|
}
|
|
17
17
|
get mappings() {
|
|
18
|
-
return this.
|
|
18
|
+
return this._mappings.get();
|
|
19
19
|
}
|
|
20
20
|
constructor(fileName, languageId, initSnapshot, vueCompilerOptions, plugins, ts) {
|
|
21
21
|
this.fileName = fileName;
|
|
@@ -26,11 +26,12 @@ class VueVirtualCode {
|
|
|
26
26
|
this.ts = ts;
|
|
27
27
|
// sources
|
|
28
28
|
this.id = 'main';
|
|
29
|
+
this._snapshot = (0, alien_signals_1.signal)(undefined);
|
|
29
30
|
// computeds
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
const snapshot = this.
|
|
31
|
+
this._vueSfc = (0, computedVueSfc_1.computedVueSfc)(this.plugins, this.fileName, this.languageId, this._snapshot);
|
|
32
|
+
this._sfc = (0, computedSfc_1.computedSfc)(this.ts, this.plugins, this.fileName, this._snapshot, this._vueSfc);
|
|
33
|
+
this._mappings = (0, alien_signals_1.computed)(() => {
|
|
34
|
+
const snapshot = this._snapshot.get();
|
|
34
35
|
return [{
|
|
35
36
|
sourceOffsets: [0],
|
|
36
37
|
generatedOffsets: [0],
|
|
@@ -38,11 +39,11 @@ class VueVirtualCode {
|
|
|
38
39
|
data: plugins_1.allCodeFeatures,
|
|
39
40
|
}];
|
|
40
41
|
});
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
42
|
+
this._embeddedCodes = (0, computedEmbeddedCodes_1.computedEmbeddedCodes)(this.plugins, this.fileName, this._sfc);
|
|
43
|
+
this._snapshot.set(initSnapshot);
|
|
43
44
|
}
|
|
44
45
|
update(newSnapshot) {
|
|
45
|
-
this.
|
|
46
|
+
this._snapshot.set(newSnapshot);
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
exports.VueVirtualCode = VueVirtualCode;
|
package/package.json
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
7
7
|
"**/*.d.ts"
|
|
8
8
|
],
|
|
9
|
+
"sideEffects": false,
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
11
12
|
"url": "https://github.com/vuejs/language-tools.git",
|
|
12
13
|
"directory": "packages/language-core"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|
|
15
|
-
"@volar/language-core": "~2.4.
|
|
16
|
-
"@vue/compiler-dom": "^3.
|
|
16
|
+
"@volar/language-core": "~2.4.8",
|
|
17
|
+
"@vue/compiler-dom": "^3.5.0",
|
|
17
18
|
"@vue/compiler-vue2": "^2.7.16",
|
|
18
|
-
"@vue/shared": "^3.
|
|
19
|
-
"
|
|
19
|
+
"@vue/shared": "^3.5.0",
|
|
20
|
+
"alien-signals": "^0.2.0",
|
|
20
21
|
"minimatch": "^9.0.3",
|
|
21
22
|
"muggle-string": "^0.4.1",
|
|
22
23
|
"path-browserify": "^1.0.1"
|
|
@@ -25,8 +26,8 @@
|
|
|
25
26
|
"@types/minimatch": "^5.1.2",
|
|
26
27
|
"@types/node": "latest",
|
|
27
28
|
"@types/path-browserify": "^1.0.1",
|
|
28
|
-
"@volar/typescript": "~2.4.
|
|
29
|
-
"@vue/compiler-sfc": "^3.
|
|
29
|
+
"@volar/typescript": "~2.4.8",
|
|
30
|
+
"@vue/compiler-sfc": "^3.5.0"
|
|
30
31
|
},
|
|
31
32
|
"peerDependencies": {
|
|
32
33
|
"typescript": "*"
|
|
@@ -36,5 +37,5 @@
|
|
|
36
37
|
"optional": true
|
|
37
38
|
}
|
|
38
39
|
},
|
|
39
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "b0af30caee2f8dfb1a8393c1b400f38e31fa4883"
|
|
40
41
|
}
|
package/lib/codegen/types.js
DELETED