@vue/language-core 3.0.4 → 3.0.6
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/codeFeatures.d.ts +0 -17
- package/lib/codegen/codeFeatures.js +0 -13
- package/lib/codegen/script/component.d.ts +1 -1
- package/lib/codegen/script/component.js +10 -14
- package/lib/codegen/script/componentSelf.js +19 -23
- package/lib/codegen/script/context.d.ts +0 -6
- package/lib/codegen/script/index.d.ts +2 -1
- package/lib/codegen/script/index.js +16 -4
- package/lib/codegen/script/scriptSetup.js +2 -2
- package/lib/codegen/script/template.d.ts +0 -1
- package/lib/codegen/script/template.js +6 -43
- package/lib/codegen/template/context.d.ts +0 -22
- package/lib/codegen/template/context.js +0 -6
- package/lib/codegen/template/element.js +17 -27
- package/lib/codegen/template/elementDirectives.js +10 -10
- package/lib/codegen/template/elementEvents.d.ts +1 -1
- package/lib/codegen/template/elementEvents.js +17 -19
- package/lib/codegen/template/elementProps.js +14 -14
- package/lib/codegen/template/index.d.ts +3 -2
- package/lib/codegen/template/index.js +25 -13
- package/lib/codegen/template/interpolation.js +2 -1
- package/lib/codegen/template/slotOutlet.js +8 -7
- package/lib/codegen/template/styleScopedClasses.js +9 -12
- package/lib/codegen/template/templateChild.js +2 -1
- package/lib/codegen/template/vFor.js +4 -3
- package/lib/codegen/template/vIf.js +2 -1
- package/lib/codegen/template/vSlot.js +9 -8
- package/lib/plugins/file-html.js +1 -1
- package/lib/plugins/file-md.js +1 -1
- package/lib/plugins/file-vue.js +17 -2
- package/lib/plugins/vue-root-tags.js +1 -1
- package/lib/plugins/vue-script-js.js +1 -1
- package/lib/plugins/vue-sfc-customblocks.js +1 -1
- package/lib/plugins/vue-sfc-scripts.js +1 -1
- package/lib/plugins/vue-sfc-styles.js +5 -5
- package/lib/plugins/vue-sfc-template.js +1 -1
- package/lib/plugins/vue-style-css.js +1 -1
- package/lib/plugins/vue-template-html.js +1 -1
- package/lib/plugins/vue-template-inline-css.js +1 -1
- package/lib/plugins/vue-template-inline-ts.js +1 -1
- package/lib/plugins/vue-tsx.d.ts +0 -22
- package/lib/plugins/vue-tsx.js +17 -20
- package/lib/plugins.js +2 -0
- package/lib/types.d.ts +3 -2
- package/lib/types.js +1 -1
- package/lib/utils/shared.d.ts +3 -1
- package/lib/utils/shared.js +13 -0
- package/lib/utils/ts.d.ts +7 -6
- package/lib/utils/ts.js +43 -66
- package/lib/virtualFile/computedSfc.js +13 -8
- package/package.json +4 -4
- package/lib/codegen/tenp.d.ts +0 -1
- package/lib/codegen/tenp.js +0 -3
- package/lib/plugins/file-css.d.ts +0 -3
- package/lib/plugins/file-css.js +0 -57
- package/lib/utils/parseCssClassNames.d.ts +0 -4
- package/lib/utils/parseCssClassNames.js +0 -17
- package/lib/utils/parseCssImports.d.ts +0 -4
- package/lib/utils/parseCssImports.js +0 -19
- package/lib/utils/parseCssVars.d.ts +0 -6
- package/lib/utils/parseCssVars.js +0 -26
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const shared_1 = require("./shared");
|
|
4
4
|
const plugin = () => {
|
|
5
5
|
return {
|
|
6
|
-
version: 2.
|
|
6
|
+
version: 2.2,
|
|
7
7
|
getEmbeddedCodes(_fileName, sfc) {
|
|
8
8
|
const result = [];
|
|
9
9
|
for (let i = 0; i < sfc.styles.length; i++) {
|
|
@@ -13,7 +13,7 @@ const plugin = () => {
|
|
|
13
13
|
id: 'style_' + i,
|
|
14
14
|
lang: style.lang,
|
|
15
15
|
});
|
|
16
|
-
if (style.
|
|
16
|
+
if (style.bindings.length) {
|
|
17
17
|
result.push({
|
|
18
18
|
id: 'style_' + i + '_inline_ts',
|
|
19
19
|
lang: 'ts',
|
|
@@ -29,11 +29,11 @@ const plugin = () => {
|
|
|
29
29
|
const style = sfc.styles[index];
|
|
30
30
|
if (embeddedFile.id.endsWith('_inline_ts')) {
|
|
31
31
|
embeddedFile.parentCodeId = 'style_' + index;
|
|
32
|
-
for (const
|
|
32
|
+
for (const binding of style.bindings) {
|
|
33
33
|
embeddedFile.content.push('(', [
|
|
34
|
-
|
|
34
|
+
binding.text,
|
|
35
35
|
style.name,
|
|
36
|
-
|
|
36
|
+
binding.offset,
|
|
37
37
|
shared_1.allCodeFeatures,
|
|
38
38
|
], ');\n');
|
|
39
39
|
}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const shouldAddSuffix = /(?<=<[^>/]+)$/;
|
|
4
4
|
const plugin = ({ modules }) => {
|
|
5
5
|
return {
|
|
6
|
-
version: 2.
|
|
6
|
+
version: 2.2,
|
|
7
7
|
compileSFCTemplate(lang, template, options) {
|
|
8
8
|
if (lang === 'html' || lang === 'md') {
|
|
9
9
|
const compiler = modules['@vue/compiler-dom'];
|
package/lib/plugins/vue-tsx.d.ts
CHANGED
|
@@ -149,28 +149,6 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
149
149
|
offset: number;
|
|
150
150
|
};
|
|
151
151
|
};
|
|
152
|
-
codeFeatures: {
|
|
153
|
-
all: import("../types").VueCodeInformation;
|
|
154
|
-
verification: import("../types").VueCodeInformation;
|
|
155
|
-
completion: import("../types").VueCodeInformation;
|
|
156
|
-
additionalCompletion: import("../types").VueCodeInformation;
|
|
157
|
-
withoutCompletion: import("../types").VueCodeInformation;
|
|
158
|
-
navigation: import("../types").VueCodeInformation;
|
|
159
|
-
navigationWithoutRename: import("../types").VueCodeInformation;
|
|
160
|
-
navigationAndCompletion: import("../types").VueCodeInformation;
|
|
161
|
-
navigationAndAdditionalCompletion: import("../types").VueCodeInformation;
|
|
162
|
-
navigationAndVerification: import("../types").VueCodeInformation;
|
|
163
|
-
withoutNavigation: import("../types").VueCodeInformation;
|
|
164
|
-
semanticWithoutHighlight: import("../types").VueCodeInformation;
|
|
165
|
-
withoutHighlight: import("../types").VueCodeInformation;
|
|
166
|
-
withoutHighlightAndNavigation: import("../types").VueCodeInformation;
|
|
167
|
-
withoutHighlightAndCompletion: import("../types").VueCodeInformation;
|
|
168
|
-
withoutHighlightAndCompletionAndNavigation: import("../types").VueCodeInformation;
|
|
169
|
-
withoutSemantic: import("../types").VueCodeInformation;
|
|
170
|
-
doNotReportTs2339AndTs2551: import("../types").VueCodeInformation;
|
|
171
|
-
doNotReportTs2353AndTs2561: import("../types").VueCodeInformation;
|
|
172
|
-
doNotReportTs6133: import("../types").VueCodeInformation;
|
|
173
|
-
};
|
|
174
152
|
resolveCodeFeatures: (features: import("../types").VueCodeInformation) => import("../types").VueCodeInformation;
|
|
175
153
|
inlineTsAsts: Map<string, import("typescript").SourceFile> | undefined;
|
|
176
154
|
inVFor: boolean;
|
package/lib/plugins/vue-tsx.js
CHANGED
|
@@ -15,7 +15,7 @@ exports.tsCodegen = new WeakMap();
|
|
|
15
15
|
const validLangs = new Set(['js', 'jsx', 'ts', 'tsx']);
|
|
16
16
|
const plugin = ctx => {
|
|
17
17
|
return {
|
|
18
|
-
version: 2.
|
|
18
|
+
version: 2.2,
|
|
19
19
|
requiredCompilerOptions: [
|
|
20
20
|
'noPropertyAccessFromIndexSignature',
|
|
21
21
|
'exactOptionalPropertyTypes',
|
|
@@ -144,8 +144,7 @@ function createTsx(fileName, sfc, ctx) {
|
|
|
144
144
|
if (getResolvedOptions().skipTemplateCodegen || !sfc.template) {
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
|
-
const
|
|
148
|
-
const codegen = (0, template_1.generateTemplate)({
|
|
147
|
+
const options = {
|
|
149
148
|
ts,
|
|
150
149
|
compilerOptions: ctx.compilerOptions,
|
|
151
150
|
vueCompilerOptions: getResolvedOptions(),
|
|
@@ -159,21 +158,23 @@ function createTsx(fileName, sfc, ctx) {
|
|
|
159
158
|
propsAssignName: getSetupPropsAssignName(),
|
|
160
159
|
inheritAttrs: getSetupInheritAttrs(),
|
|
161
160
|
selfComponentName: getComponentSelfName(),
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
161
|
+
};
|
|
162
|
+
const context = (0, template_1.createTemplateCodegenContext)(options, sfc.template.ast);
|
|
163
|
+
const codegen = (0, template_1.generateTemplate)(options, context);
|
|
164
|
+
const codes = [];
|
|
165
|
+
for (const code of codegen) {
|
|
166
|
+
if (typeof code === 'object') {
|
|
167
|
+
code[3] = context.resolveCodeFeatures(code[3]);
|
|
168
|
+
}
|
|
166
169
|
codes.push(code);
|
|
167
|
-
current = codegen.next();
|
|
168
170
|
}
|
|
169
171
|
return {
|
|
170
|
-
...
|
|
172
|
+
...context,
|
|
171
173
|
codes,
|
|
172
174
|
};
|
|
173
175
|
});
|
|
174
176
|
const getGeneratedScript = (0, alien_signals_1.computed)(() => {
|
|
175
|
-
const
|
|
176
|
-
const codegen = (0, script_1.generateScript)({
|
|
177
|
+
const options = {
|
|
177
178
|
ts,
|
|
178
179
|
compilerOptions: ctx.compilerOptions,
|
|
179
180
|
vueCompilerOptions: getResolvedOptions(),
|
|
@@ -185,16 +186,12 @@ function createTsx(fileName, sfc, ctx) {
|
|
|
185
186
|
templateCodegen: getGeneratedTemplate(),
|
|
186
187
|
destructuredPropNames: getSetupDestructuredPropNames(),
|
|
187
188
|
templateRefNames: getSetupTemplateRefNames(),
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const code = current.value;
|
|
192
|
-
codes.push(code);
|
|
193
|
-
current = codegen.next();
|
|
194
|
-
}
|
|
189
|
+
};
|
|
190
|
+
const context = (0, script_1.createScriptCodegenContext)(options);
|
|
191
|
+
const codegen = (0, script_1.generateScript)(options, context);
|
|
195
192
|
return {
|
|
196
|
-
...
|
|
197
|
-
codes,
|
|
193
|
+
...context,
|
|
194
|
+
codes: [...codegen],
|
|
198
195
|
};
|
|
199
196
|
});
|
|
200
197
|
return {
|
package/lib/plugins.js
CHANGED
|
@@ -24,6 +24,7 @@ const vue_sfc_customblocks_1 = require("./plugins/vue-sfc-customblocks");
|
|
|
24
24
|
const vue_sfc_scripts_1 = require("./plugins/vue-sfc-scripts");
|
|
25
25
|
const vue_sfc_styles_1 = require("./plugins/vue-sfc-styles");
|
|
26
26
|
const vue_sfc_template_1 = require("./plugins/vue-sfc-template");
|
|
27
|
+
const vue_style_css_1 = require("./plugins/vue-style-css");
|
|
27
28
|
const vue_template_html_1 = require("./plugins/vue-template-html");
|
|
28
29
|
const vue_template_inline_css_1 = require("./plugins/vue-template-inline-css");
|
|
29
30
|
const vue_template_inline_ts_1 = require("./plugins/vue-template-inline-ts");
|
|
@@ -37,6 +38,7 @@ function createPlugins(pluginContext) {
|
|
|
37
38
|
file_html_1.default,
|
|
38
39
|
vue_root_tags_1.default,
|
|
39
40
|
vue_script_js_1.default,
|
|
41
|
+
vue_style_css_1.default,
|
|
40
42
|
vue_template_html_1.default,
|
|
41
43
|
vue_template_inline_css_1.default,
|
|
42
44
|
vue_template_inline_ts_1.default,
|
package/lib/types.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ export interface VueCompilerOptions {
|
|
|
63
63
|
plugins: VueLanguagePlugin[];
|
|
64
64
|
experimentalModelPropName: Record<string, Record<string, boolean | Record<string, string> | Record<string, string>[]>>;
|
|
65
65
|
}
|
|
66
|
-
export declare const validVersions: readonly [2, 2.1];
|
|
66
|
+
export declare const validVersions: readonly [2, 2.1, 2.2];
|
|
67
67
|
export type VueLanguagePluginReturn = {
|
|
68
68
|
version: typeof validVersions[number];
|
|
69
69
|
name?: string;
|
|
@@ -81,6 +81,7 @@ export type VueLanguagePluginReturn = {
|
|
|
81
81
|
resolveTemplateCompilerOptions?(options: CompilerDOM.CompilerOptions): CompilerDOM.CompilerOptions;
|
|
82
82
|
compileSFCScript?(lang: string, script: string): ts.SourceFile | undefined;
|
|
83
83
|
compileSFCTemplate?(lang: string, template: string, options: CompilerDOM.CompilerOptions): CompilerDOM.CodegenResult | undefined;
|
|
84
|
+
compileSFCStyle?(lang: string, style: string): Pick<Sfc['styles'][number], 'imports' | 'bindings' | 'classNames'> | undefined;
|
|
84
85
|
updateSFCTemplate?(oldResult: CompilerDOM.CodegenResult, textChange: {
|
|
85
86
|
start: number;
|
|
86
87
|
end: number;
|
|
@@ -139,7 +140,7 @@ export interface Sfc {
|
|
|
139
140
|
text: string;
|
|
140
141
|
offset: number;
|
|
141
142
|
}[];
|
|
142
|
-
|
|
143
|
+
bindings: {
|
|
143
144
|
text: string;
|
|
144
145
|
offset: number;
|
|
145
146
|
}[];
|
package/lib/types.js
CHANGED
package/lib/utils/shared.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type * as CompilerDOM from '@vue/compiler-dom';
|
|
1
2
|
import type * as ts from 'typescript';
|
|
2
|
-
import type { TextRange } from '../types';
|
|
3
|
+
import type { Sfc, TextRange } from '../types';
|
|
3
4
|
export { hyphenate as hyphenateTag } from '@vue/shared';
|
|
4
5
|
export declare function hyphenateAttr(str: string): string;
|
|
5
6
|
export declare function getSlotsPropertyName(vueVersion: number): "$scopedSlots" | "$slots";
|
|
7
|
+
export declare function getElementTagOffsets(node: CompilerDOM.ElementNode, template: NonNullable<Sfc['template']>): number[];
|
|
6
8
|
export declare function getStartEnd(ts: typeof import('typescript'), node: ts.Node, ast: ts.SourceFile): TextRange;
|
|
7
9
|
export declare function getNodeText(ts: typeof import('typescript'), node: ts.Node, ast: ts.SourceFile): string;
|
package/lib/utils/shared.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.hyphenateTag = void 0;
|
|
4
4
|
exports.hyphenateAttr = hyphenateAttr;
|
|
5
5
|
exports.getSlotsPropertyName = getSlotsPropertyName;
|
|
6
|
+
exports.getElementTagOffsets = getElementTagOffsets;
|
|
6
7
|
exports.getStartEnd = getStartEnd;
|
|
7
8
|
exports.getNodeText = getNodeText;
|
|
8
9
|
const shared_1 = require("@vue/shared");
|
|
@@ -19,6 +20,18 @@ function hyphenateAttr(str) {
|
|
|
19
20
|
function getSlotsPropertyName(vueVersion) {
|
|
20
21
|
return vueVersion < 3 ? '$scopedSlots' : '$slots';
|
|
21
22
|
}
|
|
23
|
+
function getElementTagOffsets(node, template) {
|
|
24
|
+
const tagOffsets = [
|
|
25
|
+
template.content.indexOf(node.tag, node.loc.start.offset),
|
|
26
|
+
];
|
|
27
|
+
if (!node.isSelfClosing && template.lang === 'html') {
|
|
28
|
+
const endTagOffset = node.loc.start.offset + node.loc.source.lastIndexOf(node.tag);
|
|
29
|
+
if (endTagOffset > tagOffsets[0]) {
|
|
30
|
+
tagOffsets.push(endTagOffset);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return tagOffsets;
|
|
34
|
+
}
|
|
22
35
|
function getStartEnd(ts, node, ast) {
|
|
23
36
|
return {
|
|
24
37
|
start: ts.getTokenPosOfNode(node, ast),
|
package/lib/utils/ts.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type * as ts from 'typescript';
|
|
2
2
|
import type { RawVueCompilerOptions, VueCompilerOptions, VueLanguagePlugin } from '../types';
|
|
3
|
-
|
|
3
|
+
interface ParseConfigHost extends Omit<ts.ParseConfigHost, 'readDirectory'> {
|
|
4
|
+
}
|
|
5
|
+
export interface ParsedCommandLine extends Omit<ts.ParsedCommandLine, 'fileNames'> {
|
|
4
6
|
vueOptions: VueCompilerOptions;
|
|
5
|
-
}
|
|
6
|
-
export declare function createParsedCommandLineByJson(ts: typeof import('typescript'),
|
|
7
|
-
|
|
8
|
-
}, rootDir: string, json: any, configFileName?: string): ParsedCommandLine;
|
|
9
|
-
export declare function createParsedCommandLine(ts: typeof import('typescript'), parseConfigHost: ts.ParseConfigHost, tsConfigPath: string): ParsedCommandLine;
|
|
7
|
+
}
|
|
8
|
+
export declare function createParsedCommandLineByJson(ts: typeof import('typescript'), host: ParseConfigHost, rootDir: string, json: any, configFileName?: string): ParsedCommandLine;
|
|
9
|
+
export declare function createParsedCommandLine(ts: typeof import('typescript'), host: ParseConfigHost, configFileName: string): ParsedCommandLine;
|
|
10
10
|
export declare class CompilerOptionsResolver {
|
|
11
11
|
fileExists?: ((path: string) => boolean) | undefined;
|
|
12
12
|
configRoots: Set<string>;
|
|
@@ -21,3 +21,4 @@ export declare class CompilerOptionsResolver {
|
|
|
21
21
|
}
|
|
22
22
|
export declare function getDefaultCompilerOptions(target?: number, lib?: string, strictTemplates?: boolean): VueCompilerOptions;
|
|
23
23
|
export declare function writeGlobalTypes(vueOptions: VueCompilerOptions, writeFile: (fileName: string, data: string) => void): void;
|
|
24
|
+
export {};
|
package/lib/utils/ts.js
CHANGED
|
@@ -8,15 +8,26 @@ exports.writeGlobalTypes = writeGlobalTypes;
|
|
|
8
8
|
const shared_1 = require("@vue/shared");
|
|
9
9
|
const path_browserify_1 = require("path-browserify");
|
|
10
10
|
const globalTypes_1 = require("../codegen/globalTypes");
|
|
11
|
-
const languagePlugin_1 = require("../languagePlugin");
|
|
12
11
|
const shared_2 = require("./shared");
|
|
13
|
-
function createParsedCommandLineByJson(ts,
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
function createParsedCommandLineByJson(ts, host, rootDir, json, configFileName) {
|
|
13
|
+
const extendedPaths = new Set();
|
|
14
|
+
const proxyHost = {
|
|
15
|
+
...host,
|
|
16
|
+
readFile(fileName) {
|
|
17
|
+
if (!fileName.endsWith('/package.json')) {
|
|
18
|
+
extendedPaths.add(fileName);
|
|
19
|
+
}
|
|
20
|
+
return host.readFile(fileName);
|
|
21
|
+
},
|
|
22
|
+
readDirectory() {
|
|
23
|
+
return [];
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
const parsed = ts.parseJsonConfigFileContent(json, proxyHost, rootDir, {}, configFileName);
|
|
27
|
+
const resolver = new CompilerOptionsResolver(host.fileExists);
|
|
28
|
+
for (const extendPath of [...extendedPaths].reverse()) {
|
|
18
29
|
try {
|
|
19
|
-
const configFile = ts.readJsonConfigFile(extendPath,
|
|
30
|
+
const configFile = ts.readJsonConfigFile(extendPath, host.readFile);
|
|
20
31
|
const obj = ts.convertToObject(configFile, []);
|
|
21
32
|
const rawOptions = obj?.vueCompilerOptions ?? {};
|
|
22
33
|
resolver.addConfig(rawOptions, path_browserify_1.posix.dirname(configFile.fileName));
|
|
@@ -25,82 +36,48 @@ function createParsedCommandLineByJson(ts, parseConfigHost, rootDir, json, confi
|
|
|
25
36
|
}
|
|
26
37
|
// ensure the rootDir is added to the config roots
|
|
27
38
|
resolver.addConfig({}, rootDir);
|
|
28
|
-
const resolvedVueOptions = resolver.build();
|
|
29
|
-
const parsed = ts.parseJsonConfigFileContent(json, proxyHost.host, rootDir, {}, configFileName, undefined, (0, languagePlugin_1.getAllExtensions)(resolvedVueOptions)
|
|
30
|
-
.map(extension => ({
|
|
31
|
-
extension: extension.slice(1),
|
|
32
|
-
isMixedContent: true,
|
|
33
|
-
scriptKind: ts.ScriptKind.Deferred,
|
|
34
|
-
})));
|
|
35
|
-
// fix https://github.com/vuejs/language-tools/issues/1786
|
|
36
|
-
// https://github.com/microsoft/TypeScript/issues/30457
|
|
37
|
-
// patching ts server broke with outDir + rootDir + composite/incremental
|
|
38
|
-
parsed.options.outDir = undefined;
|
|
39
39
|
return {
|
|
40
40
|
...parsed,
|
|
41
|
-
vueOptions:
|
|
41
|
+
vueOptions: resolver.build(),
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
function createParsedCommandLine(ts,
|
|
44
|
+
function createParsedCommandLine(ts, host, configFileName) {
|
|
45
45
|
try {
|
|
46
|
-
const
|
|
47
|
-
const proxyHost =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
const extendedPaths = new Set();
|
|
47
|
+
const proxyHost = {
|
|
48
|
+
...host,
|
|
49
|
+
readFile(fileName) {
|
|
50
|
+
if (!fileName.endsWith('/package.json')) {
|
|
51
|
+
extendedPaths.add(fileName);
|
|
52
|
+
}
|
|
53
|
+
return host.readFile(fileName);
|
|
54
|
+
},
|
|
55
|
+
readDirectory() {
|
|
56
|
+
return [];
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
const config = ts.readJsonConfigFile(configFileName, proxyHost.readFile);
|
|
60
|
+
const parsed = ts.parseJsonSourceFileConfigFileContent(config, proxyHost, path_browserify_1.posix.dirname(configFileName), {}, configFileName);
|
|
61
|
+
const resolver = new CompilerOptionsResolver(host.fileExists);
|
|
62
|
+
for (const extendPath of [...extendedPaths].reverse()) {
|
|
52
63
|
try {
|
|
53
|
-
const configFile = ts.readJsonConfigFile(extendPath,
|
|
64
|
+
const configFile = ts.readJsonConfigFile(extendPath, host.readFile);
|
|
54
65
|
const obj = ts.convertToObject(configFile, []);
|
|
55
66
|
const rawOptions = obj?.vueCompilerOptions ?? {};
|
|
56
67
|
resolver.addConfig(rawOptions, path_browserify_1.posix.dirname(configFile.fileName));
|
|
57
68
|
}
|
|
58
69
|
catch { }
|
|
59
70
|
}
|
|
60
|
-
const resolvedVueOptions = resolver.build();
|
|
61
|
-
const parsed = ts.parseJsonSourceFileConfigFileContent(config, proxyHost.host, path_browserify_1.posix.dirname(tsConfigPath), {}, tsConfigPath, undefined, (0, languagePlugin_1.getAllExtensions)(resolvedVueOptions)
|
|
62
|
-
.map(extension => ({
|
|
63
|
-
extension: extension.slice(1),
|
|
64
|
-
isMixedContent: true,
|
|
65
|
-
scriptKind: ts.ScriptKind.Deferred,
|
|
66
|
-
})));
|
|
67
|
-
// fix https://github.com/vuejs/language-tools/issues/1786
|
|
68
|
-
// https://github.com/microsoft/TypeScript/issues/30457
|
|
69
|
-
// patching ts server broke with outDir + rootDir + composite/incremental
|
|
70
|
-
parsed.options.outDir = undefined;
|
|
71
71
|
return {
|
|
72
72
|
...parsed,
|
|
73
|
-
vueOptions:
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
// console.warn('Failed to resolve tsconfig path:', tsConfigPath, err);
|
|
78
|
-
return {
|
|
79
|
-
fileNames: [],
|
|
80
|
-
options: {},
|
|
81
|
-
vueOptions: getDefaultCompilerOptions(),
|
|
82
|
-
errors: [],
|
|
73
|
+
vueOptions: resolver.build(),
|
|
83
74
|
};
|
|
84
75
|
}
|
|
85
|
-
}
|
|
86
|
-
function proxyParseConfigHostForExtendConfigPaths(parseConfigHost) {
|
|
87
|
-
const extendConfigPaths = [];
|
|
88
|
-
const host = new Proxy(parseConfigHost, {
|
|
89
|
-
get(target, key) {
|
|
90
|
-
if (key === 'readFile') {
|
|
91
|
-
return (fileName) => {
|
|
92
|
-
if (!fileName.endsWith('/package.json') && !extendConfigPaths.includes(fileName)) {
|
|
93
|
-
extendConfigPaths.push(fileName);
|
|
94
|
-
}
|
|
95
|
-
return target.readFile(fileName);
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
return target[key];
|
|
99
|
-
},
|
|
100
|
-
});
|
|
76
|
+
catch { }
|
|
101
77
|
return {
|
|
102
|
-
|
|
103
|
-
|
|
78
|
+
options: {},
|
|
79
|
+
errors: [],
|
|
80
|
+
vueOptions: getDefaultCompilerOptions(),
|
|
104
81
|
};
|
|
105
82
|
}
|
|
106
83
|
class CompilerOptionsResolver {
|
|
@@ -3,9 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.templateInlineTsAsts = void 0;
|
|
4
4
|
exports.computedSfc = computedSfc;
|
|
5
5
|
const alien_signals_1 = require("alien-signals");
|
|
6
|
-
const parseCssClassNames_1 = require("../utils/parseCssClassNames");
|
|
7
|
-
const parseCssImports_1 = require("../utils/parseCssImports");
|
|
8
|
-
const parseCssVars_1 = require("../utils/parseCssVars");
|
|
9
6
|
const signals_1 = require("../utils/signals");
|
|
10
7
|
exports.templateInlineTsAsts = new WeakMap();
|
|
11
8
|
function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
|
|
@@ -106,9 +103,17 @@ function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
|
|
|
106
103
|
const getSrc = computedAttrValue('__src', base, getBlock);
|
|
107
104
|
const getModule = computedAttrValue('__module', base, getBlock);
|
|
108
105
|
const getScoped = (0, alien_signals_1.computed)(() => !!getBlock().scoped);
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
const getIr = (0, alien_signals_1.computed)(() => {
|
|
107
|
+
for (const plugin of plugins) {
|
|
108
|
+
const ast = plugin.compileSFCStyle?.(base.lang, base.content);
|
|
109
|
+
if (ast) {
|
|
110
|
+
return ast;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
const getImports = (0, signals_1.computedItems)(() => getIr()?.imports ?? [], (oldItem, newItem) => oldItem.text === newItem.text && oldItem.offset === newItem.offset);
|
|
115
|
+
const getBindings = (0, signals_1.computedItems)(() => getIr()?.bindings ?? [], (oldItem, newItem) => oldItem.text === newItem.text && oldItem.offset === newItem.offset);
|
|
116
|
+
const getClassNames = (0, signals_1.computedItems)(() => getIr()?.classNames ?? [], (oldItem, newItem) => oldItem.text === newItem.text && oldItem.offset === newItem.offset);
|
|
112
117
|
return () => mergeObject(base, {
|
|
113
118
|
get src() {
|
|
114
119
|
return getSrc();
|
|
@@ -122,8 +127,8 @@ function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
|
|
|
122
127
|
get imports() {
|
|
123
128
|
return getImports();
|
|
124
129
|
},
|
|
125
|
-
get
|
|
126
|
-
return
|
|
130
|
+
get bindings() {
|
|
131
|
+
return getBindings();
|
|
127
132
|
},
|
|
128
133
|
get classNames() {
|
|
129
134
|
return getClassNames();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"directory": "packages/language-core"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "2.4.
|
|
16
|
+
"@volar/language-core": "2.4.23",
|
|
17
17
|
"@vue/compiler-dom": "^3.5.0",
|
|
18
18
|
"@vue/compiler-vue2": "^2.7.16",
|
|
19
19
|
"@vue/shared": "^3.5.0",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@types/node": "^22.10.4",
|
|
27
27
|
"@types/path-browserify": "^1.0.1",
|
|
28
28
|
"@types/picomatch": "^4.0.0",
|
|
29
|
-
"@volar/typescript": "2.4.
|
|
29
|
+
"@volar/typescript": "2.4.23",
|
|
30
30
|
"@vue/compiler-sfc": "^3.5.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"optional": true
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "59f8cde8a5148e54294868104312b2b0f4c30d1e"
|
|
41
41
|
}
|
package/lib/codegen/tenp.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/codegen/tenp.js
DELETED
package/lib/plugins/file-css.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const parseSfc_1 = require("../utils/parseSfc");
|
|
4
|
-
const plugin = ({ vueCompilerOptions }) => {
|
|
5
|
-
return {
|
|
6
|
-
version: 2.1,
|
|
7
|
-
getLanguageId(fileName) {
|
|
8
|
-
if (vueCompilerOptions.extensions.some(ext => fileName.endsWith(ext))) {
|
|
9
|
-
return 'vue';
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
isValidFile(_fileName, languageId) {
|
|
13
|
-
return languageId === 'vue';
|
|
14
|
-
},
|
|
15
|
-
parseSFC2(_fileName, languageId, content) {
|
|
16
|
-
if (languageId !== 'vue') {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
return (0, parseSfc_1.parse)(content);
|
|
20
|
-
},
|
|
21
|
-
updateSFC(sfc, change) {
|
|
22
|
-
const blocks = [
|
|
23
|
-
sfc.descriptor.template,
|
|
24
|
-
sfc.descriptor.script,
|
|
25
|
-
sfc.descriptor.scriptSetup,
|
|
26
|
-
...sfc.descriptor.styles,
|
|
27
|
-
...sfc.descriptor.customBlocks,
|
|
28
|
-
].filter(block => !!block);
|
|
29
|
-
const hitBlock = blocks.find(block => change.start >= block.loc.start.offset && change.end <= block.loc.end.offset);
|
|
30
|
-
if (!hitBlock) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const oldContent = hitBlock.content;
|
|
34
|
-
const newContent = hitBlock.content = hitBlock.content.slice(0, change.start - hitBlock.loc.start.offset)
|
|
35
|
-
+ change.newText
|
|
36
|
-
+ hitBlock.content.slice(change.end - hitBlock.loc.start.offset);
|
|
37
|
-
// #3449
|
|
38
|
-
const endTagRegex = new RegExp(`</\\s*${hitBlock.type}\\s*>`);
|
|
39
|
-
const insertedEndTag = endTagRegex.test(oldContent) !== endTagRegex.test(newContent);
|
|
40
|
-
if (insertedEndTag) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const lengthDiff = change.newText.length - (change.end - change.start);
|
|
44
|
-
for (const block of blocks) {
|
|
45
|
-
if (block.loc.start.offset > change.end) {
|
|
46
|
-
block.loc.start.offset += lengthDiff;
|
|
47
|
-
}
|
|
48
|
-
if (block.loc.end.offset >= change.end) {
|
|
49
|
-
block.loc.end.offset += lengthDiff;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return sfc;
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
exports.default = plugin;
|
|
57
|
-
//# sourceMappingURL=file-css.js.map
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCssClassNames = parseCssClassNames;
|
|
4
|
-
const parseCssVars_1 = require("./parseCssVars");
|
|
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);
|
|
10
|
-
for (const match of matches) {
|
|
11
|
-
const matchText = match[1];
|
|
12
|
-
if (matchText) {
|
|
13
|
-
yield { offset: match.index, text: matchText };
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=parseCssClassNames.js.map
|